Merge pull request #13927 from nextcloud/remove-dead-code

Don't call apc_delete_file and apc_clear_cache anymore
This commit is contained in:
Morris Jobke 2019-02-01 10:17:55 +01:00 committed by GitHub
commit 5fe151f7c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 54 deletions

View File

@ -265,10 +265,8 @@ class Config {
flock($filePointer, LOCK_UN); flock($filePointer, LOCK_UN);
fclose($filePointer); fclose($filePointer);
// Try invalidating the opcache just for the file we wrote... if (function_exists('opcache_invalidate')) {
if (!\OC_Util::deleteFromOpcodeCache($this->configFilePath)) { @opcache_invalidate($this->configFilePath, true);
// But if that doesn't work, clear the whole cache.
\OC_Util::clearOpcodeCache();
} }
} }
} }

View File

@ -1331,56 +1331,6 @@ class OC_Util {
return $theme; return $theme;
} }
/**
* Clear a single file from the opcode cache
* This is useful for writing to the config file
* in case the opcode cache does not re-validate files
* Returns true if successful, false if unsuccessful:
* caller should fall back on clearing the entire cache
* with clearOpcodeCache() if unsuccessful
*
* @param string $path the path of the file to clear from the cache
* @return bool true if underlying function returns true, otherwise false
*/
public static function deleteFromOpcodeCache($path) {
$ret = false;
if ($path) {
// APC >= 3.1.1
if (function_exists('apc_delete_file')) {
$ret = @apc_delete_file($path);
}
// Zend OpCache >= 7.0.0, PHP >= 5.5.0
if (function_exists('opcache_invalidate')) {
$ret = @opcache_invalidate($path);
}
}
return $ret;
}
/**
* Clear the opcode cache if one exists
* This is necessary for writing to the config file
* in case the opcode cache does not re-validate files
*
* @return void
* @suppress PhanDeprecatedFunction
* @suppress PhanUndeclaredConstant
*/
public static function clearOpcodeCache() {
// APC
if (function_exists('apc_clear_cache')) {
apc_clear_cache();
}
// Zend Opcache
if (function_exists('accelerator_reset')) {
accelerator_reset();
}
// Opcache (PHP >= 5.5)
if (function_exists('opcache_reset')) {
@opcache_reset();
}
}
/** /**
* Normalize a unicode string * Normalize a unicode string
* *