#54462 closed defect (bug) (fixed)
The `post_count` option value isn't incremented when the "Hello world!" post is inserted during blog creation
Reported by: | henry.wright | Owned by: | audrasjb |
---|---|---|---|
Milestone: | 5.9 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Posts, Post Types | Keywords: | has-patch commit |
Focuses: | multisite | Cc: |
Description
The "Hello world!" post that is generated during blog creation is inserted using $wpdb
methods. wp_insert_post()
isn't used. This results in the update_posts_count()
function not being called when the post is inserted. Therefore, the post_count
option value doesn't equal 1 as expected at this point.
Attachments (1)
Change History (24)
#3
@
3 years ago
Maybe it would make sense to change this before #53443. What do you think @henrywright?
#4
@
3 years ago
I agree @audrasjb it would make sense. Would you prefer to punt both issues to 6.0 or address them both in 5.9?
#5
@
3 years ago
- Milestone changed from Awaiting Review to 5.9
- Owner set to audrasjb
- Status changed from new to reviewing
Let's address them both in 5.9 :)
This ticket was mentioned in PR #1909 on WordPress/wordpress-develop by audrasjb.
3 years ago
#6
Trac ticket: https://core.trac.wordpress.org/ticket/54462
#8
@
3 years ago
- Keywords commit added
- Status changed from reviewing to accepted
All checks passed. Marking for commit
.
#11
@
3 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
[52201] will cause the post_count
option to also be created in single-site installations, which didn't previously occur, as far as I can tell.
Would a change to something like the following be appropriate?
if ( is_multisite() ) { update_posts_count(); }
#12
@
3 years ago
- Keywords dev-feedback added; commit removed
That's a fair point. I'm still checking everywhere but yes it looks like the option wasn't created before on single-site installs.
In that case, I'm not sure update_posts_count
is better than update_option( 'post_count', 1 );
.
It looks like wp_install_defaults
can not be overridden by any hook, so I'd say that updating the option directly is more straightforward. Any thoughts @dlh?
#13
@
3 years ago
@dlh why would we not want post_count to be incremented for single site installs?
A single site install can become a network install at a future date, at which point it will get a post_count option value
#14
@
3 years ago
@dlh I agree though the is_multisite()
condition would avoid adding the option to single site installs unnecessarily.
#15
@
3 years ago
@audrasjb Sure, either works. The function call is just a small amount of future-proofing should it become possible to change the default content or should core install two posts by default.
@henrywright For one thing, I don't think the value would be incremented properly on a single-site installation, would it? The only two calls to it currently are in ms-blogs.php
. Expanding post_count
to work in single-site installations might still make sense, but it seems like a separate effort.
#16
@
3 years ago
- Keywords dev-feedback removed
I agree this would be a separate effort.
Let's use the change you proposed @dlh then, you're right it's better in case the current implementation change in the future.
#17
@
3 years ago
@dlh agree it wouldn't be incremented or decremented in a single site install. Expanding post_count to work fully in a single site install was my thoughts but I agree that effort is for another day :)
54462.diff updates the post_count option value when the "Hello world!" post is inserted during blog creation.