Heres la fuente de clearstatcache en php PHP 5.2.14-si le ayuda.
PHPAPI void php_clear_stat_cache(TSRMLS_D)
{
if (BG(CurrentStatFile)) {
efree(BG(CurrentStatFile));
BG(CurrentStatFile) = NULL;
}
if (BG(CurrentLStatFile)) {
efree(BG(CurrentLStatFile));
BG(CurrentLStatFile) = NULL;
}
realpath_cache_clean(TSRMLS_C);
}
PHP_FUNCTION(clearstatcache)
{
if (ZEND_NUM_ARGS()) {
WRONG_PARAM_COUNT;
}
php_clear_stat_cache(TSRMLS_C);
}
- PHPAPI void php_clear_stat_cache(TSRMLS_D)
- {
- if (BG(CurrentStatFile)) {
- efree(BG(CurrentStatFile));
- BG(CurrentStatFile) = NULL;
- }
- if (BG(CurrentLStatFile)) {
- efree(BG(CurrentLStatFile));
- BG(CurrentLStatFile) = NULL;
- }
- realpath_cache_clean(TSRMLS_C);
- }
-
- PHP_FUNCTION(clearstatcache)
- {
- if (ZEND_NUM_ARGS()) {
- WRONG_PARAM_COUNT;
- }
- php_clear_stat_cache(TSRMLS_C);
- }
Al parecer, para realizar un seguimiento de sólo el último archivo utilizado. Hice la siguiente prueba. Si ejecuta la prueba tal y como son, y van en a través de FTP para eliminar los tres archivos txt, mientras que el guión es el sueño ()-ción, recibo errores durante los primeros dos archivos, y un mtime válido para el último archivo. Si me quite mi clearstatcache () llame, me da tres errores.
Esto me lleva a creer PHP sólo lleva un registro del último archivo, y no una colección de archivos que se usan en todo el guión.
<pre><?php
$filenames = array(
'one.txt',
'two.txt',
'three.txt'
);
foreach($filenames as $filename)
{
file_put_contents($filename, $filename);
}
sleep(2);
foreach($filenames as $filename)
{
printf('%1$s: %2$s%3$s', $filename, filemtime($filename), PHP_EOL);
}
flush(); ob_flush();
//clearstatcache();
sleep(10); // Delete files via FTP/SSH here
foreach($filenames as $filename)
{
printf('%1$s: %2$s%3$s', $filename, filemtime($filename), PHP_EOL);
}
flush();
?></pre>
- <pre><?php
-
- $filenames = array(
- 'one.txt',
- 'two.txt',
- 'three.txt'
- );
-
- foreach($filenames as $filename)
- {
- file_put_contents($filename, $filename);
- }
-
- sleep(2);
-
- foreach($filenames as $filename)
- {
- printf('%1$s: %2$s%3$s', $filename, filemtime($filename), PHP_EOL);
- }
- flush(); ob_flush();
- //clearstatcache();
-
- sleep(10); // Delete files via FTP/SSH here
-
- foreach($filenames as $filename)
- {
- printf('%1$s: %2$s%3$s', $filename, filemtime($filename), PHP_EOL);
- }
- flush();
-
- ?></pre>
En el clearstatcache página del manual, la nota sobre la lista de argumentos Nombre de archivo del PHP 5.3 tan Im adivinar PHP 5.3 + realmente mantiene la memoria caché en la colección de archivos utilizado.
He intentado pasar los parámetros a clearstatcache en PHP 5.2.6 que he sentado aquí a mi lado. Me sale el siguiente error, que cuando miro hacia atrás en el código fuente de clearstatcache, tiene sentido debido a que su lanzamiento de un WRONG_PARAM_COUNT "," error theres cualquier momento uno o más argumentos pasados en 5.2 .*
contar parámetro incorrecto para clearstatcache ()
Luego tenemos el código fuente para clearstatcache en PHP 5.3.3 que acepta argumentos. Al parecer, para utilizar sólo el argumento de nombre de archivo $ si el argumento es VERDADERO realpath sin embargo.
PHPAPI void php_clear_stat_cache(zend_bool clear_realpath_cache, const char *filename, int filename_len TSRMLS_DC)
{
/* always clear CurrentStatFile and CurrentLStatFile even if filename is not NULL
* as it may contains outdated data (e.g. "nlink" for a directory when deleting a file
* in this directory, as shown by lstat_stat_variation9.phpt) */
if (BG(CurrentStatFile)) {
efree(BG(CurrentStatFile));
BG(CurrentStatFile) = NULL;
}
if (BG(CurrentLStatFile)) {
efree(BG(CurrentLStatFile));
BG(CurrentLStatFile) = NULL;
}
if (clear_realpath_cache) {
if (filename != NULL) {
realpath_cache_del(filename, filename_len TSRMLS_CC);
} else {
realpath_cache_clean(TSRMLS_C);
}
}
}
PHP_FUNCTION(clearstatcache)
{
zend_bool clear_realpath_cache = 0;
char *filename = NULL;
int filename_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|bs", &clear_realpath_cache, &filename, &filename_len) == FAILURE) {
return;
}
php_clear_stat_cache(clear_realpath_cache, filename, filename_len TSRMLS_CC);
}
- PHPAPI void php_clear_stat_cache(zend_bool clear_realpath_cache, const char *filename, int filename_len TSRMLS_DC)
- {
- /* always clear CurrentStatFile and CurrentLStatFile even if filename is not NULL
- * as it may contains outdated data (e.g. "nlink" for a directory when deleting a file
- * in this directory, as shown by lstat_stat_variation9.phpt) */
- if (BG(CurrentStatFile)) {
- efree(BG(CurrentStatFile));
- BG(CurrentStatFile) = NULL;
- }
- if (BG(CurrentLStatFile)) {
- efree(BG(CurrentLStatFile));
- BG(CurrentLStatFile) = NULL;
- }
- if (clear_realpath_cache) {
- if (filename != NULL) {
- realpath_cache_del(filename, filename_len TSRMLS_CC);
- } else {
- realpath_cache_clean(TSRMLS_C);
- }
- }
- }
-
- PHP_FUNCTION(clearstatcache)
- {
- zend_bool clear_realpath_cache = 0;
- char *filename = NULL;
- int filename_len = 0;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|bs", &clear_realpath_cache, &filename, &filename_len) == FAILURE) {
- return;
- }
-
- php_clear_stat_cache(clear_realpath_cache, filename, filename_len TSRMLS_CC);
- }
No creo que tengo una copia del 5,3 por pasar mis pruebas en este momento.
Strong with this one, the sudo is.