Issue #1933636 by sun: PhpStorage\FileStorage tries to write a file using the same name of MTimeProtectedFileStorage's directory name.
parent
8d98947271
commit
241356f06d
|
@ -152,6 +152,14 @@ class MTimeProtectedFastFileStorage extends FileStorage {
|
||||||
* Returns the full path of the containing directory where the file is or should be stored.
|
* Returns the full path of the containing directory where the file is or should be stored.
|
||||||
*/
|
*/
|
||||||
protected function getContainingDirectoryFullPath($name) {
|
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);
|
return $this->directory . '/' . str_replace('/', '#', $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,12 @@ abstract class MTimeProtectedFileStorageBase extends PhpStorageTestBase {
|
||||||
$name = 'simpletest.php';
|
$name = 'simpletest.php';
|
||||||
$php->save($name, '<?php');
|
$php->save($name, '<?php');
|
||||||
$expected_root_directory = sys_get_temp_dir() . '/php/simpletest';
|
$expected_root_directory = sys_get_temp_dir() . '/php/simpletest';
|
||||||
|
if (substr($name, -4) === '.php') {
|
||||||
|
$expected_directory = $expected_root_directory . '/' . substr($name, 0, -4);
|
||||||
|
}
|
||||||
|
else {
|
||||||
$expected_directory = $expected_root_directory . '/' . $name;
|
$expected_directory = $expected_root_directory . '/' . $name;
|
||||||
|
}
|
||||||
$directory_mtime = filemtime($expected_directory);
|
$directory_mtime = filemtime($expected_directory);
|
||||||
$expected_filename = $expected_directory . '/' . hash_hmac('sha256', $name, $this->secret . $directory_mtime) . '.php';
|
$expected_filename = $expected_directory . '/' . hash_hmac('sha256', $name, $this->secret . $directory_mtime) . '.php';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue