[wp-trac] [WordPress Trac] #40682: get_current_blog_id() and get_current_network_id() are loaded before absint()

WordPress Trac noreply at wordpress.org
Sat Feb 23 15:35:39 UTC 2019


#40682: get_current_blog_id() and get_current_network_id() are loaded before
absint()
--------------------------------+------------------------------
 Reporter:  wonderboymusic      |       Owner:  (none)
     Type:  defect (bug)        |      Status:  new
 Priority:  normal              |   Milestone:  Awaiting Review
Component:  Networks and Sites  |     Version:  3.5
 Severity:  normal              |  Resolution:
 Keywords:  needs-patch         |     Focuses:  multisite
--------------------------------+------------------------------

Comment (by johnjamesjacoby):

 > I suggest moving get_current_blog_id() and get_current_network_id() to
 wp-includes/functions.php as a first step

 Unfortunately this will break more than it fixes.

 Caching plugins will commonly need to access the current blog ID and
 current network ID to build their unique cache keys, so the stack of
 function calls needs to be available before `advanced-cache.php` is loaded
 via `wp-settings.php`.

 I believe @wonderboymusic is correct that not only is a race condition
 occurring, both of the `get_current_blog_id()` and
 `get_current_network_id()` functions should not contain any function calls
 or just-in-time setting/calculation of these variables – they probably
 need to be set already and simply return global values.

 ----

 That said, the simpler fix for this ''exact'' issue might just be to
 relocate `absint()` to `load.php`. That's sufficient for Super Cache and
 Spider Cache in my testing.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/40682#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list