本文整理汇总了PHP中clearstatcache函数的典型用法代码示例。如果您正苦于以下问题:PHP clearstatcache函数的具体用法?PHP clearstatcache怎么用?PHP clearstatcache使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了clearstatcache函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCloseStream
public function testCloseStream()
{
//ensure all basic stream stuff works
$sourceFile = OC::$SERVERROOT . '/tests/data/lorem.txt';
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile('.txt');
$file = 'close://' . $tmpFile;
$this->assertTrue(file_exists($file));
file_put_contents($file, file_get_contents($sourceFile));
$this->assertEquals(file_get_contents($sourceFile), file_get_contents($file));
unlink($file);
clearstatcache();
$this->assertFalse(file_exists($file));
//test callback
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile('.txt');
$file = 'close://' . $tmpFile;
$actual = false;
$callback = function ($path) use(&$actual) {
$actual = $path;
};
\OC\Files\Stream\Close::registerCallback($tmpFile, $callback);
$fh = fopen($file, 'w');
fwrite($fh, 'asd');
fclose($fh);
$this->assertSame($tmpFile, $actual);
}
示例2: __construct
public function __construct()
{
$defaults = array('chuser' => false, 'uid' => 99, 'gid' => 99, 'maxTimes' => 0, 'maxMemory' => 0, 'limitMemory' => 0, 'log' => '/tmp/' . get_class($this) . '.log', 'pid' => '/tmp/' . get_class($this) . '.pid', 'help' => "Usage:\n\n{$_SERVER['_']} " . __FILE__ . " start|stop|restart|status|help\n\n");
$this->_options += $defaults;
ini_set('memory_limit', $this->_options['limitMemory']);
clearstatcache();
}
示例3: generateEntityManagerProxies
/**
* Generate doctrine proxy classes for extended entities for the given entity manager
*
* @param EntityManager $em
*/
protected function generateEntityManagerProxies(EntityManager $em)
{
$isAutoGenerated = $em->getConfiguration()->getAutoGenerateProxyClasses();
if (!$isAutoGenerated) {
$proxyDir = $em->getConfiguration()->getProxyDir();
if (!empty($this->cacheDir) && $this->kernelCacheDir !== $this->cacheDir && strpos($proxyDir, $this->kernelCacheDir) === 0) {
$proxyDir = $this->cacheDir . substr($proxyDir, strlen($this->kernelCacheDir));
}
$metadataFactory = $em->getMetadataFactory();
$proxyFactory = $em->getProxyFactory();
$extendConfigs = $this->extendConfigProvider->getConfigs(null, true);
foreach ($extendConfigs as $extendConfig) {
if (!$extendConfig->is('is_extend')) {
continue;
}
if ($extendConfig->in('state', [ExtendScope::STATE_NEW])) {
continue;
}
$entityClass = $extendConfig->getId()->getClassName();
$proxyFileName = $proxyDir . DIRECTORY_SEPARATOR . '__CG__' . str_replace('\\', '', $entityClass) . '.php';
$metadata = $metadataFactory->getMetadataFor($entityClass);
$proxyFactory->generateProxyClasses([$metadata], $proxyDir);
clearstatcache(true, $proxyFileName);
}
}
}
示例4: testComposerInstallAndUpdate
/**
* Tests a simple composer install without core, but adding core later.
*/
public function testComposerInstallAndUpdate()
{
$exampleScaffoldFile = $this->tmpDir . DIRECTORY_SEPARATOR . 'index.php';
$this->assertFileNotExists($exampleScaffoldFile, 'Scaffold file should not be exist.');
$this->composer('install');
$this->assertFileExists($this->tmpDir . DIRECTORY_SEPARATOR . 'core', 'Drupal core is installed.');
$this->assertFileExists($exampleScaffoldFile, 'Scaffold file should be automatically installed.');
$this->fs->remove($exampleScaffoldFile);
$this->assertFileNotExists($exampleScaffoldFile, 'Scaffold file should not be exist.');
$this->composer('drupal-scaffold');
$this->assertFileExists($exampleScaffoldFile, 'Scaffold file should be installed by "drupal-scaffold" command.');
foreach (['8.0.1', '8.1.x-dev'] as $version) {
// We touch a scaffold file, so we can check the file was modified after
// the scaffold update.
touch($exampleScaffoldFile);
$mtime_touched = filemtime($exampleScaffoldFile);
// Requiring a newer version triggers "composer update"
$this->composer('require --update-with-dependencies drupal/core:"' . $version . '"');
clearstatcache();
$mtime_after = filemtime($exampleScaffoldFile);
$this->assertNotEquals($mtime_after, $mtime_touched, 'Scaffold file was modified by composer update. (' . $version . ')');
}
// We touch a scaffold file, so we can check the file was modified after
// the custom commandscaffold update.
touch($exampleScaffoldFile);
clearstatcache();
$mtime_touched = filemtime($exampleScaffoldFile);
$this->composer('drupal-scaffold');
clearstatcache();
$mtime_after = filemtime($exampleScaffoldFile);
$this->assertNotEquals($mtime_after, $mtime_touched, 'Scaffold file was modified by custom command.');
}
示例5: initRunFolder
public function initRunFolder()
{
clearstatcache();
if (!File::exists($this->tmpRunFolder) && !is_dir($this->tmpRunFolder)) {
$this->filesystem->mkdir($this->tmpRunFolder);
}
}
示例6: is_page
function is_page($page, $clearcache = FALSE)
{
if ($clearcache) {
clearstatcache();
}
return file_exists(get_filename($page));
}
示例7: write
/**
* {@inheritdoc}
*/
public function write($key, $content)
{
$dir = dirname($key);
if (!is_dir($dir)) {
if (false === @mkdir($dir, 0777, true)) {
clearstatcache(false, $dir);
if (!is_dir($dir)) {
throw new RuntimeException(sprintf('Unable to create the cache directory (%s).', $dir));
}
}
} elseif (!is_writable($dir)) {
throw new RuntimeException(sprintf('Unable to write in the cache directory (%s).', $dir));
}
$tmpFile = tempnam($dir, basename($key));
if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $key)) {
@chmod($key, 0666 & ~umask());
if (self::FORCE_BYTECODE_INVALIDATION == ($this->options & self::FORCE_BYTECODE_INVALIDATION)) {
// Compile cached file into bytecode cache
if (function_exists('opcache_invalidate')) {
opcache_invalidate($key, true);
} elseif (function_exists('apc_compile_file')) {
apc_compile_file($key);
}
}
return;
}
throw new RuntimeException(sprintf('Failed to write cache file "%s".', $key));
}
示例8: testExecute
public function testExecute()
{
$application = $this->getApplication();
$application->add(new ListCommand());
$command = $this->getApplication()->find('dev:module:create');
$root = getcwd();
// delete old module
if (is_dir($root . '/N98Magerun_UnitTest')) {
$filesystem = new Filesystem();
$filesystem->recursiveRemoveDirectory($root . '/N98Magerun_UnitTest');
clearstatcache();
}
$commandTester = new CommandTester($command);
$commandTester->execute(array('command' => $command->getName(), '--add-all' => true, '--add-setup' => true, '--add-readme' => true, '--add-composer' => true, '--modman' => true, '--description' => 'Unit Test Description', '--author-name' => 'Unit Test', '--author-email' => 'n98-magerun@example.com', 'vendorNamespace' => 'N98Magerun', 'moduleName' => 'UnitTest'));
$this->assertFileExists($root . '/N98Magerun_UnitTest/composer.json');
$this->assertFileExists($root . '/N98Magerun_UnitTest/readme.md');
$moduleBaseFolder = $root . '/N98Magerun_UnitTest/src/app/code/local/N98Magerun/UnitTest/';
$this->assertFileExists($moduleBaseFolder . 'etc/config.xml');
$this->assertFileExists($moduleBaseFolder . 'Block');
$this->assertFileExists($moduleBaseFolder . 'Model');
$this->assertFileExists($moduleBaseFolder . 'Helper');
$this->assertFileExists($moduleBaseFolder . 'data/n98magerun_unittest_setup');
$this->assertFileExists($moduleBaseFolder . 'sql/n98magerun_unittest_setup');
// delete old module
if (is_dir($root . '/N98Magerun_UnitTest')) {
$filesystem = new Filesystem();
$filesystem->recursiveRemoveDirectory($root . '/N98Magerun_UnitTest');
clearstatcache();
}
}
示例9: doRewrite
function doRewrite()
{
clearstatcache();
if (!($file = fopen($this->path, "r"))) {
$this->error = true;
return false;
}
$content = fread($file, filesize($this->path));
fclose($file);
foreach ($this->rewrite as $key => $val) {
$val = str_replace('$', '\\$', $val);
if (is_int($val) && preg_match("/(define\\()([\"'])(" . $key . ")\\2,\\s*([0-9]+)\\s*\\)/", $content)) {
$content = preg_replace("/(define\\()([\"'])(" . $key . ")\\2,\\s*([0-9]+)\\s*\\)/", "define('" . $key . "', " . $val . ")", $content);
$this->report .= _OKIMG . sprintf(_INSTALL_L121, "<b>{$key}</b>", $val) . "<br />\n";
} elseif (preg_match("/(define\\()([\"'])(" . $key . ")\\2,\\s*([\"'])(.*?)\\4\\s*\\)/", $content)) {
$content = preg_replace("/(define\\()([\"'])(" . $key . ")\\2,\\s*([\"'])(.*?)\\4\\s*\\)/", "define('" . $key . "', '" . $val . "')", $content);
$this->report .= _OKIMG . sprintf(_INSTALL_L121, "<b>{$key}</b>", $val) . "<br />\n";
} else {
$this->error = true;
$this->report .= _NGIMG . sprintf(_INSTALL_L122, "<b>{$key}</b>", $val) . "<br />\n";
}
}
if (!($file = fopen($this->path, "w"))) {
$this->error = true;
return false;
}
if (fwrite($file, $content) == -1) {
fclose($file);
$this->error = true;
return false;
}
fclose($file);
return true;
}
示例10: setup
public function setup()
{
clearstatcache();
$fs = new Adapter\Local(__DIR__ . '/');
$fs->deleteDir('files');
$fs->createDir('files');
}
示例11: handleRequest
/**
* Handle a single request
*
* @param string method request method
* @param string query query string
* @param [:string] headers request headers
* @param string data post data
* @param peer.Socket socket
* @return int
*/
public function handleRequest($method, $query, array $headers, $data, Socket $socket)
{
$url = parse_url($query);
$f = new File($this->docroot, strtr(preg_replace('#\\.\\./?#', '/', urldecode($url['path'])), '/', DIRECTORY_SEPARATOR));
if (!is_file($f->getURI())) {
return call_user_func($this->notFound, $this, $socket, $url['path']);
}
// Implement If-Modified-Since/304 Not modified
$lastModified = $f->lastModified();
if ($mod = $this->header($headers, 'If-Modified-Since')) {
$d = strtotime($mod);
if ($lastModified <= $d) {
$this->sendHeader($socket, 304, 'Not modified', []);
return 304;
}
}
clearstatcache();
try {
$f->open(File::READ);
} catch (IOException $e) {
$this->sendErrorMessage($socket, 500, 'Internal server error', $e->getMessage());
$f->close();
return 500;
}
// Send OK header and data in 8192 byte chunks
$this->sendHeader($socket, 200, 'OK', ['Last-Modified: ' . gmdate('D, d M Y H:i:s T', $lastModified), 'Content-Type: ' . MimeType::getByFileName($f->getFilename()), 'Content-Length: ' . $f->size()]);
while (!$f->eof()) {
$socket->write($f->read(8192));
}
$f->close();
return 200;
}
示例12: boot
/**
* {@inheritDoc}
*/
public function boot()
{
// Register an autoloader for proxies to avoid issues when unserializing them
// when the ORM is used.
if ($this->container->hasParameter('doctrine.orm.proxy_namespace')) {
$namespace = $this->container->getParameter('doctrine.orm.proxy_namespace');
$dir = $this->container->getParameter('doctrine.orm.proxy_dir');
$proxyGenerator = null;
if ($this->container->getParameter('doctrine.orm.auto_generate_proxy_classes')) {
// See https://github.com/symfony/symfony/pull/3419 for usage of references
$container =& $this->container;
$proxyGenerator = function ($proxyDir, $proxyNamespace, $class) use(&$container) {
$originalClassName = ClassUtils::getRealClass($class);
/** @var $registry Registry */
$registry = $container->get('doctrine');
// Tries to auto-generate the proxy file
/** @var $em \Doctrine\ORM\EntityManager */
foreach ($registry->getManagers() as $em) {
if (!$em->getConfiguration()->getAutoGenerateProxyClasses()) {
continue;
}
$metadataFactory = $em->getMetadataFactory();
if ($metadataFactory->isTransient($originalClassName)) {
continue;
}
$classMetadata = $metadataFactory->getMetadataFor($originalClassName);
$em->getProxyFactory()->generateProxyClasses(array($classMetadata));
clearstatcache(true, Autoloader::resolveFile($proxyDir, $proxyNamespace, $class));
break;
}
};
}
$this->autoloader = Autoloader::register($dir, $namespace, $proxyGenerator);
}
}
示例13: isValid
function isValid($id, $group = 'default', $doNotTestCacheValidity = false)
{
$this->_id = $id;
$this->_group = $group;
if ($this->_caching) {
$this->_setRefreshTime();
$this->_setFileName($id, $group);
clearstatcache();
if ($this->_memoryCaching) {
if (isset($this->_memoryCachingArray[$this->_file])) {
return true;
}
if ($this->_onlyMemoryCaching) {
return false;
}
}
if ($doNotTestCacheValidity || is_null($this->_refreshTime)) {
if (file_exists($this->_file)) {
return true;
}
} else {
if (file_exists($this->_file) && @filemtime($this->_file) > $this->_refreshTime) {
return true;
}
}
}
return false;
}
示例14: cron_auto_del_temp_download
function cron_auto_del_temp_download()
{
$dir = NV_ROOTDIR . '/' . NV_TEMP_DIR;
$result = true;
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if (preg_match('/^(' . nv_preg_quote(NV_TEMPNAM_PREFIX) . ')[a-zA-Z0-9\\_\\.]+$/', $file)) {
if (filemtime($dir . '/' . $file) + 600 < NV_CURRENTTIME) {
if (is_file($dir . '/' . $file)) {
if (!@unlink($dir . '/' . $file)) {
$result = false;
}
} else {
$rt = nv_deletefile($dir . '/' . $file, true);
if ($rt[0] == 0) {
$result = false;
}
}
}
}
}
closedir($dh);
clearstatcache();
}
return $result;
}
示例15: debug
function debug($data)
{
global $timezone;
if (function_exists("date_default_timezone_set")) {
// php 5.1.x
@date_default_timezone_set($timezone);
}
$debug_file = "./tfu.log";
$debug_string = date("m.d.Y G:i:s") . " - " . $data . "\n\n";
if (file_exists($debug_file)) {
if (filesize($debug_file) > 1000000) {
// debug file max = 1MB !
$debug_file_local = fopen($debug_file, 'w');
} else {
$debug_file_local = fopen($debug_file, 'a');
}
fputs($debug_file_local, $debug_string);
fclose($debug_file_local);
} else {
if (is_writeable(dirname(__FILE__))) {
$debug_file_local = fopen($debug_file, 'w');
fputs($debug_file_local, $debug_string);
fclose($debug_file_local);
clearstatcache();
} else {
error_log($debug_string, 0);
}
}
}