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

Invalidate the Yoast SEO PHP files and directories instead of flushin… #20921

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions wp-seo-main.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,28 @@ function wpseo_init() {
WPSEO_Meta::init();

if ( version_compare( WPSEO_Options::get( 'version', 1 ), WPSEO_VERSION, '<' ) ) {
if ( function_exists( 'opcache_reset' ) ) {
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Prevent notices when opcache.restrict_api is set.
@opcache_reset();
require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php';
require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php';
require_once ABSPATH . 'wp-admin/includes/file.php';
WP_Filesystem();

/*
* We invalidate each subdir and the main files instead of the whole `wordpress-seo` dir
* to avoid any timeout or resource exhaustion when building from source.
*/
if ( function_exists( 'wp_opcache_invalidate' ) ) {
// Since WP 5.5.
wp_opcache_invalidate( WPSEO_PATH . 'wp-seo-main.php' );
wp_opcache_invalidate( WPSEO_PATH . 'wp-seo.php' );
}
if ( function_exists( 'wp_opcache_invalidate_directory' ) ) {
// Since WP 6.2.
wp_opcache_invalidate_directory( WPSEO_PATH . 'admin' );
wp_opcache_invalidate_directory( WPSEO_PATH . 'inc' );
wp_opcache_invalidate_directory( WPSEO_PATH . 'lib' );
wp_opcache_invalidate_directory( WPSEO_PATH . 'src' );
wp_opcache_invalidate_directory( WPSEO_PATH . 'vendor' );
wp_opcache_invalidate_directory( WPSEO_PATH . 'vendor_prefixed' );
}

new WPSEO_Upgrade();
Expand Down