Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#40036 closed defect (bug) (fixed)

Re-save Network Settings ruin starter content

Reported by: berfayvel's profile berfayvel Owned by: swissspidy's profile swissspidy
Milestone: 4.7.4 Priority: normal
Severity: normal Version: 4.7.2
Component: Networks and Sites Keywords: has-patch has-unit-tests
Focuses: multisite Cc:


On fresh multisite install, I re-save data in wp-admin/network/settings.php. Then I create a sub-site.

When try to edit the sub-site's starter content Sample Page, the content is just blank (no content, only title).

Then I create more sub-sites. But it still same (Sample Page content is blank).

No error generated.

Attachments (3)

40036.patch (4.3 KB) - added by shadyvb 7 years ago.
Update wp_install_defaults to properly add default content to first page/content if they're saved as empty values
40036.tests.patch (6.6 KB) - added by shadyvb 7 years ago.
40036.diff (6.8 KB) - added by swissspidy 7 years ago.

Download all attachments as: .zip

Change History (9)

#1 @SergeyBiryukov
7 years ago

  • Focuses multisite added
  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 4.7.4

Hi @berfayvel, welcome to WordPress Trac!

Thanks for the report, the First Page content is indeed blank in Network Settings.

#2 @shadyvb
7 years ago

The reason for this is that only the first_post value is inserted into the initial DB schema update at
Neither first_page / first_comment values are inserted to the database, and once the settings page is saved, the *empty* value is actually saved then.

So, the actual call while setting up new sites in wp_install_defaults is get_option( 'first_page', $first_page ), and the way get_option currently works is that it only returns the passed default value if it *does not exist* in the database, not if it *exists* but empty.

The behaviour is not consistent between the first post and the first page/comment, because wp_install_default does not do the same with first_post, instead it will always insert the default content if the saved value is empty ( the post is created anyway, so no use in making it empty ).

Working on patch / tests and will post shortly.

7 years ago

Update wp_install_defaults to properly add default content to first page/content if they're saved as empty values

7 years ago

#3 @swissspidy
7 years ago

  • Owner set to swissspidy
  • Status changed from new to assigned

#4 @swissspidy
7 years ago

  • Keywords has-patch has-unit-tests added; needs-patch removed

7 years ago

#5 @swissspidy
7 years ago

40036.diff splits up the previous test into 3 tests to make it easier to work with.

#6 @swissspidy
7 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 40296:

Multisite: Ensure first page/post/comment content is not empty when setting up a new site.

This prevents creating page without any content when the options are populated with an empty string.

Props shadyvb.
Fixes #40036.

Note: See TracTickets for help on using tickets.