Issue #1933636 by sun: PhpStorage\FileStorage tries to write a file using the same name of MTimeProtectedFileStorage's directory name.

8.0.x
Alex Pott 2014-04-06 21:40:03 +01:00
parent 8d98947271
commit 241356f06d
2 changed files with 14 additions and 1 deletions

View File

@ -152,6 +152,14 @@ class MTimeProtectedFastFileStorage extends FileStorage {
* Returns the full path of the containing directory where the file is or should be stored.
*/
protected function getContainingDirectoryFullPath($name) {
// Remove the .php file extension from the directory name.
// Within a single directory, a subdirectory cannot have the same name as a
// file. Thus, when switching between MTimeProtectedFastFileStorage and
// FileStorage, the subdirectory or the file cannot be created in case the
// other file type exists already.
if (substr($name, -4) === '.php') {
$name = substr($name, 0, -4);
}
return $this->directory . '/' . str_replace('/', '#', $name);
}

View File

@ -66,7 +66,12 @@ abstract class MTimeProtectedFileStorageBase extends PhpStorageTestBase {
$name = 'simpletest.php';
$php->save($name, '<?php');
$expected_root_directory = sys_get_temp_dir() . '/php/simpletest';
$expected_directory = $expected_root_directory . '/' . $name;
if (substr($name, -4) === '.php') {
$expected_directory = $expected_root_directory . '/' . substr($name, 0, -4);
}
else {
$expected_directory = $expected_root_directory . '/' . $name;
}
$directory_mtime = filemtime($expected_directory);
$expected_filename = $expected_directory . '/' . hash_hmac('sha256', $name, $this->secret . $directory_mtime) . '.php';