Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trac 56975 Stub functions in noop and restore caching #3872

Conversation

hellofromtonya
Copy link
Contributor

Option 2: Stubbing the functions in wp-admin/includes/noop.php:

As detailed in the trac ticket, this PR implements option 2 to prevent the fatal error due to load-styles.php only loading a very small subset of WordPress, thus not having the wp_cache_*() functions available.

This PR:

How to test:

  • Add the following to wp-config.php:
define( 'CONCATENATE_SCRIPTS', true );
define( 'WP_DEBUG', false );
define( 'SCRIPT_DEBUG', false );
  • Load WP Admin, which will then load load-styles.php as a CSS file.

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


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@azaozz
Copy link
Contributor

azaozz commented Jan 20, 2023

+1 for stubbing, LGTM.

Comment on lines +112 to +114
function wp_cache_get() {
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function wp_cache_get() {
return false;
}
function wp_cache_get( $key = '', $group = '', $force = false, &$found = null ) {
$found = false;
return false;
}

This is to account for the case in which $found is used to account for false as a possible cached value.

$cache_found = false;
if ( null === $this->posts ) {
$cached_results = wp_cache_get( $cache_key, 'posts', false, $cache_found );

I don't know how much it's used in core but it would be good to avoid an error if it is.

@felixarntz
Copy link
Member

@hellofromtonya This option makes sense to me, however I have an overarching concern now, see https://core.trac.wordpress.org/ticket/56975#comment:65.

@hellofromtonya
Copy link
Contributor Author

Closing in favor of #3887, which was committed as the solution 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants