diff --git a/core/includes/install.inc b/core/includes/install.inc index ebcab90..066884c 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -176,34 +176,37 @@ function drupal_get_database_types() { * @throws Exception */ function drupal_clear_opcode_cache($filepath) { + // This setting can be On/Off or 1/0, but when the setting is Off + // the returned value is an empty string instead of 0. + $empty_values = array("", 0); clearstatcache(TRUE, $filepath); try { - if (function_exists('opcache_invalidate')) { + if (extension_loaded('Zend OPcache')) { $timestamps = ini_get('opcache.validate_timestamps'); if (!$timestamps || ($timestamps && ini_get('opcache.revalidate_freq') != 0)) { opcache_invalidate($filepath); } } - if (function_exists('apc_delete_file') && ini_get('apc.stat') == 0) { + if (extension_loaded('apc') && in_array(ini_get('apc.stat'), $empty_values)) { apc_delete_file($filepath); } - if (function_exists('wincache_refresh_if_changed')) { - if (ini_get('wincache.fcndetect') == 0 || ini_get('wincache.chkinterval') == 0) { + if (extension_loaded('wincache')) { + if (in_array(ini_get('wincache.fcndetect'), $empty_values) || ini_get('wincache.chkinterval') == 0) { wincache_refresh_if_changed(array($filepath)); } } - if (function_exists('xcache_clear_cache')) { - // Use @ error suppression. - @xcache_clear_cache(XC_TYPE_PHP); + if (extension_loaded('XCache') && in_array(ini_get('xcache.stat'), $empty_values)) { + for ($i = 0; $i < xcache_count(XC_TYPE_PHP); $i++) { + xcache_clear_cache(XC_TYPE_PHP, $i); + } } - if (function_exists('eaccelerator_clear')) { - // Use @ error suppression. - @eaccelerator_clear(); + if (extension_loaded('eaccelerator')) { + eaccelerator_clear(); } } catch (Exception $e) { - throw new Exception(t('Failed to clear the opcode cache for %settings. For the duration of the installation it is recommended to either disable the opcode cache, or reconfigure it to allow code changes to be seen immediately.', array('%settings' => $settings_file))); + throw new Exception(t('Failed to clear the opcode cache for %file. For the duration of the installation it is recommended to either disable the opcode cache, or reconfigure it to allow code changes to be seen immediately.', array('%file' => $filepath))); } }