本文整理匯總了PHP中OC_Util::clearOpcodeCache方法的典型用法代碼示例。如果您正苦於以下問題:PHP OC_Util::clearOpcodeCache方法的具體用法?PHP OC_Util::clearOpcodeCache怎麽用?PHP OC_Util::clearOpcodeCache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OC_Util
的用法示例。
在下文中一共展示了OC_Util::clearOpcodeCache方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: writeData
/**
* Writes the config file
*
* Saves the config to the config file.
*
* @throws HintException If the config file cannot be written to
* @throws \Exception If no file lock can be acquired
*/
private function writeData()
{
// Create a php file ...
$content = "<?php\n";
$content .= '$CONFIG = ';
$content .= var_export($this->cache, true);
$content .= ";\n";
touch($this->configFilePath);
$filePointer = fopen($this->configFilePath, 'r+');
// Prevent others not to read the config
chmod($this->configFilePath, 0640);
// File does not exist, this can happen when doing a fresh install
if (!is_resource($filePointer)) {
$url = \OC_Helper::linkToDocs('admin-dir_permissions');
throw new HintException("Can't write into config directory!", 'This can usually be fixed by ' . '<a href="' . $url . '" target="_blank">giving the webserver write access to the config directory</a>.');
}
// Try to acquire a file lock
if (!flock($filePointer, LOCK_EX)) {
throw new \Exception(sprintf('Could not acquire an exclusive lock on the config file %s', $this->configFilePath));
}
// Write the config and release the lock
ftruncate($filePointer, 0);
fwrite($filePointer, $content);
fflush($filePointer);
flock($filePointer, LOCK_UN);
fclose($filePointer);
// Try invalidating the opcache just for the file we wrote...
if (!\OC_Util::deleteFromOpcodeCache($this->configFilePath)) {
// But if that doesn't work, clear the whole cache.
\OC_Util::clearOpcodeCache();
}
}
示例2: writeData
/**
* @brief Writes the config file
*
* Saves the config to the config file.
*
*/
private function writeData()
{
// Create a php file ...
$content = "<?php\n";
if ($this->debugMode) {
$content .= "define('DEBUG',true);\n";
}
$content .= '$CONFIG = ';
$content .= var_export($this->cache, true);
$content .= ";\n";
// Write the file
$result = @file_put_contents($this->configFilename, $content);
if (!$result) {
$defaults = new \OC_Defaults();
$url = \OC_Helper::linkToDocs('admin-dir-permissions');
throw new HintException("Can't write into config directory!", 'This can usually be fixed by ' . '<a href="' . $url . '" target="_blank">giving the webserver write access to the config directory</a>.');
}
// Prevent others not to read the config
@chmod($this->configFilename, 0640);
\OC_Util::clearOpcodeCache();
}
示例3: writeData
/**
* Writes the config file
*
* Saves the config to the config file.
*
* @throws HintException If the config file cannot be written to
* @throws \Exception If no file lock can be acquired
*/
private function writeData()
{
// Create a php file ...
$content = "<?php\n";
$content .= '$CONFIG = ';
$content .= var_export($this->cache, true);
$content .= ";\n";
touch($this->configFilePath);
$filePointer = fopen($this->configFilePath, 'r+');
// Prevent others not to read the config
chmod($this->configFilePath, 0640);
// File does not exist, this can happen when doing a fresh install
if (!is_resource($filePointer)) {
// TODO fix this via DI once it is very clear that this doesn't cause side effects due to initialization order
// currently this breaks app routes but also could have other side effects especially during setup and exception handling
$url = \OC::$server->getURLGenerator()->linkToDocs('admin-dir_permissions');
throw new HintException("Can't write into config directory!", 'This can usually be fixed by ' . '<a href="' . $url . '" target="_blank" rel="noreferrer">giving the webserver write access to the config directory</a>.');
}
// Try to acquire a file lock
if (!flock($filePointer, LOCK_EX)) {
throw new \Exception(sprintf('Could not acquire an exclusive lock on the config file %s', $this->configFilePath));
}
// Write the config and release the lock
ftruncate($filePointer, 0);
fwrite($filePointer, $content);
fflush($filePointer);
flock($filePointer, LOCK_UN);
fclose($filePointer);
// Try invalidating the opcache just for the file we wrote...
if (!\OC_Util::deleteFromOpcodeCache($this->configFilePath)) {
// But if that doesn't work, clear the whole cache.
\OC_Util::clearOpcodeCache();
}
}
示例4: writeData
/**
* @brief Writes the config file
* @return bool
*
* Saves the config to the config file.
*
*/
public static function writeData()
{
// Create a php file ...
$defaults = new OC_Defaults();
$content = "<?php\n\$CONFIG = ";
$content .= var_export(self::$cache, true);
$content .= ";\n";
$filename = OC::$SERVERROOT . "/config/config.php";
// Write the file
$result = @file_put_contents($filename, $content);
if (!$result) {
$tmpl = new OC_Template('', 'error', 'guest');
$tmpl->assign('errors', array(1 => array('error' => "Can't write into config directory 'config'", 'hint' => 'This can usually be fixed by ' . '<a href="' . $defaults->getDocBaseUrl() . '/server/5.0/admin_manual/installation/installation_source.html#set-the-directory-permissions" target="_blank">giving the webserver write access to the config directory</a>.')));
$tmpl->printPage();
exit;
}
// Prevent others not to read the config
@chmod($filename, 0640);
OC_Util::clearOpcodeCache();
return true;
}