Make WordPress Core

Opened 7 months ago

Last modified 2 weeks ago

#59871 assigned enhancement

Prime further options in `wp_load_core_site_options()`

Reported by: peterwilsoncc's profile peterwilsoncc Owned by: peterwilsoncc's profile peterwilsoncc
Milestone: 6.7 Priority: normal
Severity: normal Version:
Component: Options, Meta APIs Keywords: has-patch
Focuses: multisite, performance Cc:

Description

In Multisite, individual database queries are made to query a number of commonly used options.

On each request:

  • WPLANG
  • nonce_key
  • nonce_salt

On each authenticated request:

  • auth_key
  • auth_salt

The *_(salt|key) requests are only made if the constant is not defined or uses the default phrase put your unique phrase here.

Follow up to #56913.

Attachments (1)

Screenshot 2024-05-20 at 23.19.21.png (264.7 KB) - added by spacedmonkey 5 weeks ago.

Download all attachments as: .zip

Change History (19)

This ticket was mentioned in Slack in #core-performance by joemcgill. View the logs.


7 months ago

#2 @joemcgill
7 months ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

Thanks @peterwilsoncc. Moving to Future Release for now with needs-patch. This seems like it could be a good-first-bug candidate. Do you have ideas about the implementation that you'd want to share?

This ticket was mentioned in PR #6588 on WordPress/wordpress-develop by @spacedmonkey.


5 weeks ago
#3

  • Keywords has-patch added; needs-patch removed

Requires #61053.

Use wp_prime_site_option_caches to prime option / network option caches if not defined as const.

Trac ticket: https://core.trac.wordpress.org/ticket/59871

#4 follow-up: @spacedmonkey
5 weeks ago

I have put together a PR for this that uses wp_prime_site_option_caches. I think this a little cleaner solution.

@peterwilsoncc commented on PR #6588:


5 weeks ago
#5

@spacedmonkey It looks like you accidentally pushed to the WordPress org's copy of the repo. Are you able to reopen from your fork so the branch doesn't get deleted when the bots sync every minute or so.

#6 in reply to: ↑ 4 @peterwilsoncc
5 weeks ago

Replying to spacedmonkey:

I have put together a PR for this that uses wp_prime_site_option_caches. I think this a little cleaner solution.

Yes, that's much cleaner.

This ticket was mentioned in Slack in #core-performance by spacedmonkey. View the logs.


4 weeks ago

This ticket was mentioned in PR #6597 on WordPress/wordpress-develop by @spacedmonkey.


4 weeks ago
#8

Requires #61053.

Use wp_prime_site_option_caches to prime option / network option caches if not defined as const.

@spacedmonkey commented on PR #6588:


4 weeks ago
#9

@spacedmonkey It looks like you accidentally pushed to the WordPress org's copy of the repo. Are you able to reopen from your fork so the branch doesn't get deleted when the bots sync every minute or so.

Done https://github.com/WordPress/wordpress-develop/pull/6597

#10 @spacedmonkey
4 weeks ago

  • Milestone changed from Future Release to 6.6

Testing instruction:

Comment / remove out the following files of wp-config.php

define( 'AUTH_KEY',          '#O9e87Y5ebxFl6M-TN9Q$~|r|`0$qlc=-dDwRgh6(ol9pAAGL?V5Z& M!4CPSY[(' );
define( 'SECURE_AUTH_KEY',   'l49R6x5DzDOx%sF#JVu*V-bpg4|!<G<M,|V[gwUFZ@4(CSHC.fv7^oXt!-U2N-fo' );
define( 'LOGGED_IN_KEY',     ']k]@J3Gn&v~CCC|c5;<9F.R@X-g~u`tfMV9xRg9F:WzQHUOy3,?|c:h6=FQB,z^[' );
define( 'NONCE_KEY',         'kT{LWm&zB,I`R3WgecY(ih?g{Mpu[M?dy._vfwN8 a?+cGAt~|o!|zUtLG~2H<oY' );
define( 'AUTH_SALT',         'B;q9^gGo;*|z^)M7()=<+0BHoP?s3fs4<6sGCmTDNvC@*[>[RFbD]dOk@ZHXI&R@' );
define( 'SECURE_AUTH_SALT',  'Z*FMM?m<x!6?E~%r_j>HPDxC/^W-7%(T}}*;zEzi9Qzm?HE=XL1L7)0Layb<Y~`F' );
define( 'LOGGED_IN_SALT',    'MCNC|L[^rD&9J`+dR1m;geR%0:N:F>x FU1;)dmt,_Y+.4G7dE.dakBwq4r0knx#' );
define( 'NONCE_SALT',        'bij7+;xA87bL~2w=+N5&eo1RH]hFN>o<S>M0&uH8K2~] g~F#aA_<D;Q01k8O;ig' );

Load a home page.
Use query monito to see the call to wp_prime_network_option_caches in wp_salt.

This ticket was mentioned in Slack in #core-performance by mukeshpanchal27. View the logs.


4 weeks ago

This ticket was mentioned in Slack in #core-performance by spacedmonkey. View the logs.


3 weeks ago

This ticket was mentioned in PR #6720 on WordPress/wordpress-develop by @peterwilsoncc.


3 weeks ago
#13

Use the wp_prime_site_option_caches() function to prime options containing the various salts in a single database query.

I'd really like to add some tests for these but am not able to as the salts are cached in a static withing wp_salt and by the time the test is run they will have been added to the static elsewhere.

https://github.com/WordPress/wordpress-develop/blob/5706a203849740ab4479136e5fd22803f942f5ef/src/wp-includes/pluggable.php#L2425-L2437

I did test these locally with the code in this gist and it worked as expected when running the following commands:

./vendor/bin/phpunit --filter Tests_Pluggable_wp_salt -c tests/phpunit/multisite.xml
./vendor/bin/phpunit --filter Tests_Pluggable_wp_salt

Trac ticket: https://core.trac.wordpress.org/ticket/59871

This ticket was mentioned in Slack in #core-performance by spacedmonkey. View the logs.


2 weeks ago

#16 @spacedmonkey
2 weeks ago

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

#17 @peterwilsoncc
2 weeks ago

  • Milestone changed from 6.6 to 6.7
  • Type changed from defect (bug) to enhancement

As getting the salt options works just fine, I think this is an enhancement rather than a bug. This ticket doesn't fix anything, it just makes it a little nicer.

As I've missed the 6.6 Beta, I'll move this to the 6.7 milestone.

Sorry I forgot to set the type correctly when opening the ticket.

This ticket was mentioned in Slack in #core-performance by peterwilsoncc. View the logs.


2 weeks ago

Note: See TracTickets for help on using tickets.