Commit ea1b9551 authored by catch's avatar catch

Issue #1748880 by mikeytown2: Only clear the stat cache for the files we care about.

parent da08a2f7
......@@ -421,7 +421,7 @@ function image_save(stdClass $image, $destination = NULL) {
}
if ($return = image_toolkit_invoke('save', $image, array($destination))) {
// Clear the cached file size and refresh the image information.
clearstatcache();
clearstatcache(TRUE, $destination);
$image->info = image_get_info($destination, $image->toolkit);
if (drupal_chmod($destination)) {
......
......@@ -655,7 +655,7 @@ function _isArchive($p_filename=NULL)
if ($p_filename == NULL) {
$p_filename = $this->_tarname;
}
clearstatcache();
clearstatcache(TRUE, $p_filename);
return @is_file($p_filename) && !@is_link($p_filename);
}
// }}}
......@@ -1086,7 +1086,7 @@ function _writeHeader($p_filename, $p_stored_filename)
$v_size = sprintf("%11s ", DecOct(0));
} else {
$v_typeflag = '';
clearstatcache();
clearstatcache(TRUE, $p_filename);
$v_size = sprintf("%11s ", DecOct($v_info['size']));
}
......@@ -1642,7 +1642,7 @@ function _extractList($p_path, &$p_list_detail, $p_mode,
}
// ----- Check the file size
clearstatcache();
clearstatcache(TRUE, $v_header['filename']);
if (filesize($v_header['filename']) != $v_header['size']) {
$this->_error('Extracted file '.$v_header['filename']
.' does not have the correct file size \''
......@@ -1755,7 +1755,7 @@ function _openAppend()
if (!$this->_openReadWrite())
return false;
clearstatcache();
clearstatcache(TRUE, $this->_tarname);
$v_size = filesize($this->_tarname);
// We might have zero, one or two end blocks.
......@@ -1801,7 +1801,7 @@ function _append($p_filelist, $p_add_dir='', $p_remove_dir='')
*/
function _dirCheck($p_dir)
{
clearstatcache();
clearstatcache(TRUE, $p_dir);
if ((@is_dir($p_dir)) || ($p_dir == ''))
return true;
......
......@@ -204,7 +204,7 @@ protected function getContainingDirectoryFullPath($name) {
* Clears PHP's stat cache and returns the directory's mtime.
*/
protected function getUncachedMTime($directory) {
clearstatcache();
clearstatcache(TRUE, $directory);
return filemtime($directory);
}
}
......@@ -132,7 +132,7 @@ function chmod($mode) {
$output = @chmod($this->getLocalPath(), $mode);
// We are modifying the underlying file here, so we have to clear the stat
// cache so that PHP understands that URI has changed too.
clearstatcache();
clearstatcache(TRUE, $this->getLocalPath());
return $output;
}
......
......@@ -111,7 +111,10 @@ function testRevisions() {
// TODO: This seems like a bug in File API. Clearing the stat cache should
// not be necessary here. The file really is deleted, but stream wrappers
// doesn't seem to think so unless we clear the PHP file stat() cache.
clearstatcache();
clearstatcache($node_file_r1->uri);
clearstatcache($node_file_r2->uri);
clearstatcache($node_file_r3->uri);
clearstatcache($node_file_r4->uri);
// Call system_cron() to clean up the file. Make sure the timestamp
// of the file is older than DRUPAL_MAXIMUM_TEMP_FILE_AGE.
......
......@@ -83,7 +83,7 @@ function assertSameFile($file1, $file2) {
*/
function assertFilePermissions($filepath, $expected_mode, $message = NULL) {
// Clear out PHP's file stat cache to be sure we see the current value.
clearstatcache();
clearstatcache(TRUE, $filepath);
// Mask out all but the last three octets.
$actual_mode = fileperms($filepath) & 0777;
......@@ -118,7 +118,7 @@ function assertFilePermissions($filepath, $expected_mode, $message = NULL) {
*/
function assertDirectoryPermissions($directory, $expected_mode, $message = NULL) {
// Clear out PHP's file stat cache to be sure we see the current value.
clearstatcache();
clearstatcache(TRUE, $directory);
// Mask out all but the last three octets.
$actual_mode = fileperms($directory) & 0777;
......
......@@ -294,7 +294,7 @@ function testDeletePicture() {
$this->assertFalse($file, 'File is removed from database');
// Clear out PHP's file stat cache so we see the current value.
clearstatcache();
clearstatcache(TRUE, $pic_path);
$this->assertFalse(is_file($pic_path), 'File is removed from file system');
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment