diff --git a/src/includes/classes/MenuPageOptions.php b/src/includes/classes/MenuPageOptions.php index af56d8ae..5a2ef880 100644 --- a/src/includes/classes/MenuPageOptions.php +++ b/src/includes/classes/MenuPageOptions.php @@ -272,10 +272,10 @@ public function __construct() if ($this->plugin->functionIsPossible('opcache_reset')) { echo '
'."\n"; echo '

'.__('Clear the PHP OPCache Too?', SLUG_TD).'

'."\n"; - echo '

'.sprintf(__('If you clear the cache manually, do you want %1$s to clear the PHP OPCache too? This is highly recommended, so that all PHP files in the server\'s opcode cache are purged from memory also.', SLUG_TD), esc_html(NAME)).'

'."\n"; + echo '

'.sprintf(__('If you clear the cache manually, do you want %1$s to clear the PHP OPCache too? This is not necessary, but if you want a truly clean start, this will clear all PHP files in the server\'s opcode cache also. Note: If you don\'t already know what the PHP OPcache is, it is suggested that you leave this disabled. It really is not necessary. This is just an added feature for advanced users.', SLUG_TD), esc_html(NAME)).'

'."\n"; echo '

'."\n"; } if ($this->plugin->functionIsPossible('s2clean')) { @@ -557,7 +557,6 @@ public function __construct() echo '

'.__('Note: please remember that your entries here should be formatted as a line-delimited list; e.g., one exclusion pattern per line.', SLUG_TD).'

'."\n"; echo ' '."\n"; - echo ''."\n"; /* ----------------------------------------------------------------------------------------- */ @@ -667,7 +666,6 @@ public function __construct() /* ----------------------------------------------------------------------------------------- */ - echo '
'."\n"; echo ' '."\n"; diff --git a/src/includes/classes/Plugin.php b/src/includes/classes/Plugin.php index 4def7633..52695f47 100644 --- a/src/includes/classes/Plugin.php +++ b/src/includes/classes/Plugin.php @@ -254,9 +254,10 @@ public function setup() $this->default_options = array( /* Core/systematic plugin options. */ - 'version' => VERSION, - 'welcomed' => '0', // `0|1` welcomed yet? - 'crons_setup' => '0', // A timestamp when last set up. + 'version' => VERSION, + 'welcomed' => '0', // `0|1` welcomed yet? + + 'crons_setup' => '0', // A timestamp when last set up. 'crons_setup_on_namespace' => '', // The namespace on which they were set up. 'crons_setup_with_cache_cleanup_schedule' => '', // The cleanup schedule selected by site owner during last setup. 'crons_setup_on_wp_with_schedules' => '', // A sha1 hash of `wp_get_schedules()` @@ -286,7 +287,7 @@ public function setup() 'cache_clear_admin_bar_roles_caps' => '', // Comma-delimited list of roles/caps. 'cache_clear_cdn_enable' => '0', // `0|1`. - 'cache_clear_opcache_enable' => '1', // `0|1`. + 'cache_clear_opcache_enable' => '0', // `0|1`. 'cache_clear_s2clean_enable' => '0', // `0|1`. 'cache_clear_eval_code' => '', // PHP code. 'cache_clear_urls' => '', // Line-delimited list of URLs. @@ -318,10 +319,10 @@ public function setup() /* Related to exclusions. */ - 'exclude_uris' => '', // Empty string or line-delimited patterns. + 'exclude_uris' => '', // Empty string or line-delimited patterns. 'exclude_client_side_uris' => '', // Line-delimited list of URIs. - 'exclude_refs' => '', // Empty string or line-delimited patterns. - 'exclude_agents' => 'w3c_validator', // Empty string or line-delimited patterns. + 'exclude_refs' => '', // Empty string or line-delimited patterns. + 'exclude_agents' => 'w3c_validator', // Empty string or line-delimited patterns. /* Related to version salt. */ @@ -363,7 +364,7 @@ public function setup() 'cdn_invalidation_var' => 'iv', // A query string variable name. 'cdn_invalidation_counter' => '1', // Current version counter. - 'cdn_over_ssl' => '0', // `0|1`; enable SSL compat? + 'cdn_over_ssl' => '0', // `0|1`; enable SSL compat? 'cdn_when_logged_in' => '0', // `0|1`; enable when logged in? 'cdn_whitelisted_extensions' => '', // Whitelisted extensions. diff --git a/src/includes/closures/Plugin/InstallUtils.php b/src/includes/closures/Plugin/InstallUtils.php index f789048b..5fdb38b2 100644 --- a/src/includes/closures/Plugin/InstallUtils.php +++ b/src/includes/closures/Plugin/InstallUtils.php @@ -371,6 +371,8 @@ } $self->cacheUnlock($cache_lock); // Release. + $self->clearAcDropinFromOpcacheByForce(); + return true; }; @@ -408,6 +410,8 @@ if (file_put_contents($advanced_cache_file, '') !== 0) { return false; // Failure. } + $self->clearAcDropinFromOpcacheByForce(); + return true; }; @@ -435,6 +439,8 @@ return false; // Not possible; or outright failure. } } + $self->clearAcDropinFromOpcacheByForce(); + return true; // Deletion success. }; diff --git a/src/includes/closures/Plugin/WcpOpcacheUtils.php b/src/includes/closures/Plugin/WcpOpcacheUtils.php index 767eaa76..f6b8448d 100644 --- a/src/includes/closures/Plugin/WcpOpcacheUtils.php +++ b/src/includes/closures/Plugin/WcpOpcacheUtils.php @@ -9,10 +9,11 @@ * * @param bool $manually True if wiping is done manually. * @param boolean $maybe Defaults to a true value. + * @param array $files Optional; wipe only specific files? * * @return integer Total keys wiped. */ -$self->wipeOpcache = function ($manually = false, $maybe = true) use ($self) { +$self->wipeOpcache = function ($manually = false, $maybe = true, $files = array()) use ($self) { $counter = 0; // Initialize counter. if ($maybe && !$self->options['cache_clear_opcache_enable']) { @@ -27,10 +28,14 @@ if (empty($status->opcache_enabled)) { return $counter; // Not necessary. } - if (!isset($status->opcache_statistics->num_cached_keys)) { + if (empty($status->opcache_statistics->num_cached_keys)) { return $counter; // Not possible. } - if (opcache_reset()) { // True if a reset occurs. + if ($files) { // Specific files? + foreach ($files as $_file) { + $counter += (int) opcache_invalidate($_file, true); + } // unset($_file); // Housekeeping. + } elseif (opcache_reset()) { // True if a reset occurs. $counter += $status->opcache_statistics->num_cached_keys; } return $counter; @@ -41,7 +46,7 @@ * * @since 151002 Adding OPCache support. * - * @param bool $manually True if wiping is done manually. + * @param bool $manually True if clearing is done manually. * @param boolean $maybe Defaults to a true value. * * @return integer Total keys cleared. @@ -52,4 +57,15 @@ } return 0; // Not applicable. }; + +/* + * Clear AC class file from Opcache (by force). + * + * @since 151215 Adding OPCache support. + * + * @return integer Total keys cleared. + */ +$self->clearAcDropinFromOpcacheByForce = function () use ($self) { + return $self->wipeOpcache(false, false, array(WP_CONTENT_DIR.'/advanced-cache.php')); +}; /*[/pro]*/