Make WordPress Core

Opened 8 years ago

Closed 7 years ago

Last modified 6 years ago

#40948 closed enhancement (fixed)

Load meta files earlier in `wp-settings.php`

Reported by: flixos90's profile flixos90 Owned by: flixos90's profile flixos90
Milestone: 5.1 Priority: normal
Severity: normal Version:
Component: Bootstrap/Load Keywords: ms-roadmap
Focuses: multisite Cc:

Description

We're currently working on bringing meta functionality to sites and networks. While this is still in the early stages of discussion, we're sure that we would at least like to enable plugins to introduce this functionality (DB table and API), even if we come to the conclusion that site and network meta are not eligible for core itself (see #37923 and #25344 for background discussion on site and network meta).

A general problem is that the meta functionality is not available when bootstrapping multisite and when using classes like WP_Site_Query and WP_Network_Query (which need to support meta_query). Therefore the meta files should be loaded earlier, in particular:

  • wp-includes/meta.php
  • wp-includes/class-wp-meta-query.php
  • wp-includes/class-wp-metadata-lazyloader.php

They should be loaded together with the other "early" WordPress files. This does not only make sense for the above specific use-case, but also because the meta API is a generally reusable basic database interaction API and allows to work with arbitrary "name-value" pairs, just like options. The Options API is also available early, and the Meta API should follow.

Change History (24)

#1 @johnjamesjacoby
8 years ago

Big +1 from me.

#2 @flixos90
8 years ago

  • Summary changed from Load meta files earlier in `ms-settings.php` to Load meta files earlier in `wp-settings.php`

Whoops, typo in the summary.

This ticket was mentioned in Slack in #core-multisite by flixos90. View the logs.


7 years ago

#4 @flixos90
7 years ago

  • Keywords 2nd-opinion removed
  • Milestone changed from Awaiting Review to Future Release

This is a requirement for the site meta API we're planning (and also for network meta if we do it).

#5 @flixos90
7 years ago

  • Keywords ms-roadmap added

These tickets belong to our planned roadmap (a few of them not per final decision), so flagging with a keyword for better overview.

This ticket was mentioned in Slack in #core-multisite by jeremyfelt. View the logs.


7 years ago

#7 @flixos90
7 years ago

As noted during the work on #37923, wp-includes/formatting.php needs to be loaded early as well, since the metadata API requires parts of it.

This ticket was mentioned in Slack in #core-multisite by flixos90. View the logs.


7 years ago

This ticket was mentioned in Slack in #core-multisite by flixos90. View the logs.


7 years ago

#10 @jeremyfelt
7 years ago

I'm not really opposed to getting this in earlier than later. It would be nice to know that not having these available earlier is currently blocking someone's external work.

From a core perspective, we'll be moving formatting.php and meta.php up in the boot process in #37923 anyway. The others can be moved as part of #40229 if they aren't already.

This ticket was mentioned in Slack in #core-multisite by jeremyfelt. View the logs.


7 years ago

This ticket was mentioned in Slack in #core-multisite by flixos90. View the logs.


7 years ago

#13 @flixos90
7 years ago

  • Milestone changed from Future Release to 5.0

#14 @flixos90
7 years ago

In 42835:

Bootstrap: Load formatting.php and meta.php earlier in wp-settings.php.

This change is necessary to enable multisite-specific metadata functionality during the multisite bootstrap process.

See #40948.

#15 @flixos90
7 years ago

For #40229 we'll still need to move the class-wp-meta-query.php to be loaded earlier, as mentioned before.

#16 @flixos90
7 years ago

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

#17 @barry
7 years ago

This change seems to have broken the installer -

PHP Fatal error:  Cannot redeclare wptexturize() (previously declared in /wp-includes/formatting.php:51) in /wp-includes/formatting.php on line 313
Last edited 7 years ago by barry (previous) (diff)

#18 @azaozz
7 years ago

  • Severity changed from normal to critical

As Barry points out, shuffling load order is really dangerous and brings up edge cases. It shouldn't be done without unit tests...

Should [42835] be reverted until all edge cases are fixed?

Also, formatting.php shouldn't be needed for accessing the db. I'd rather move sanitize_key() or introduce a similar function than load a file that is clearly intended for formatting the PHP output while accessing the db.

#19 @ocean90
7 years ago

  • Severity changed from critical to normal

Noting that the above is already fixed in [42988]. What other edge cases are there? And how would you find them if things get reverted?

#20 @flixos90
7 years ago

@barry Seems that this bug had indeed already been reported via #43609 and fixed in [42988] as @ocean90 stated above. Can you verify that solves the problem on wp.com?

Reverting [42835] is not really an option since other functionality is built on it that requires some of the functions to be loaded early. I'd like to emphasize what was said before, that reverting furthermore wouldn't allow us to find these bugs. If there's anything else, please report on this ticket or as an individual ticket referencing this one, and we'll get it fixed.

#21 @flixos90
7 years ago

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

In 43009:

Bootstrap: Load class-wp-meta-query.php earlier in wp-settings.php.

This change is necessary to enable multisite-specific meta query functionality during the multisite bootstrap process.

Fixes #40948. See #40229.

#22 @flixos90
7 years ago

  • Keywords needs-dev-note added

#23 @flixos90
6 years ago

  • Milestone changed from 5.0 to 5.1

#24 @flixos90
6 years ago

  • Keywords needs-dev-note removed
Note: See TracTickets for help on using tickets.