Project

General

Profile

Bug #23193 » 15133_v4-4.4.diff

Administrator Admin, 2011-01-10 21:18

View differences:

tests/t3lib/t3lib_divTest.php (working copy)
$this->assertFalse($fixPermissionsResult);
}
/**
* @test
*/
public function fixPermissionsSetsPermissionsWithRelativeFileReference() {
if (TYPO3_OS == 'WIN') {
$this->markTestSkipped('fixPermissions() tests not available on Windows');
}
$filename = 'typo3temp/' . uniqid('test_');
t3lib_div::writeFileToTypo3tempDir(PATH_site . $filename, '42');
chmod($filename, 0742);
// Set target permissions and run method
$GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0660';
$fixPermissionsResult = t3lib_div::fixPermissions($filename);
// Get actual permissions and clean up
clearstatcache();
$resultFilePermissions = substr(decoct(fileperms(PATH_site . $filename)), 2);
unlink(PATH_site . $filename);
// Test if everything was ok
$this->assertTrue($fixPermissionsResult);
$this->assertEquals($resultFilePermissions, '0660');
}
///////////////////////////////
// Tests concerning mkdir
///////////////////////////////
t3lib/class.t3lib_div.php (working copy)
/**
* Sets the file system mode and group ownership of a file or a folder.
*
* @param string Absolute filepath of file or folder, must not be escaped.
* @param string Path of file or folder, must not be escaped. Path can be absolute or relative.
* @param boolean If set, also fixes permissions of files and folders in the folder (if $path is a folder)
* @return mixed TRUE on success, FALSE on error, always TRUE on Windows OS
*/
public static function fixPermissions($path, $recursive = FALSE) {
if (TYPO3_OS != 'WIN') {
$result = FALSE;
// Make path absolute
if (!self::isAbsPath($path)) {
$path = self::getFileAbsFileName($path, FALSE);
}
if (self::isAllowedAbsPath($path)) {
if (@is_file($path)) {
// "@" is there because file is not necessarily OWNED by the user
(6-6/7)