From 547f785993625c12775381cbaf48cd762f5fedd8 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Thu, 7 May 2009 16:18:42 +0000 Subject: [PATCH] Supress chmod() errors, they're annoying and very common. In all liklihood, the wiki can display the image with whatever permissions it was created to begin with. Also introduce the 'fileMode' parameter for $wgLocalFileRepo/$wgForeignFileRepos. Fixes bug 18326 --- RELEASE-NOTES | 4 +++- includes/DefaultSettings.php | 2 ++ includes/filerepo/FSRepo.php | 9 +++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 6c989416f4..8d7379ba61 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -22,6 +22,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 18222) $wgMinimalPasswordLength default is now 1 * $wgSessionHandler can be used to configure session.save_handler +* $wgLocalFileRepo/$wgForeignFileRepos now have a 'fileMode' parameter to + be used when uploading/moving files === New features in 1.16 === @@ -113,7 +115,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 6802) profileinfo.php now also work on other database servers than MySQL * (bug 16925) Diffs no longer fail when $wgExternalDiffEngine is set to 'wikidiff' or 'wikidiff2' but extension is not installed - +* (bug 18326) Chmod errors in file repos have been hidden == API changes in 1.16 == diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 4168ecea0f..0c146d51ff 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -208,6 +208,8 @@ $wgFileStore['deleted']['hash'] = 3; ///< 3-level subdirectory split * May be 'paranoid' to remove all parameters from error messages, 'none' to * leave the paths in unchanged, or 'simple' to replace paths with * placeholders. Default for LocalRepo is 'simple'. + * fileMode This allows wikis to set the file mode when uploading/moving files. Default + * is 0644. * * These settings describe a foreign MediaWiki installation. They are optional, and will be ignored * for local repositories: diff --git a/includes/filerepo/FSRepo.php b/includes/filerepo/FSRepo.php index 95158cdaae..7a3a1622a1 100644 --- a/includes/filerepo/FSRepo.php +++ b/includes/filerepo/FSRepo.php @@ -6,7 +6,7 @@ * @ingroup FileRepo */ class FSRepo extends FileRepo { - var $directory, $deletedDir, $url, $deletedHashLevels; + var $directory, $deletedDir, $url, $deletedHashLevels, $fileMode; var $fileFactory = array( 'UnregisteredLocalFile', 'newFromTitle' ); var $oldFileFactory = false; var $pathDisclosureProtection = 'simple'; @@ -23,6 +23,7 @@ class FSRepo extends FileRepo { $this->deletedHashLevels = isset( $info['deletedHashLevels'] ) ? $info['deletedHashLevels'] : $this->hashLevels; $this->deletedDir = isset( $info['deletedDir'] ) ? $info['deletedDir'] : false; + $this->fileMode = isset( $info['fileMode'] ) ? $info['fileMode'] : 0644; } /** @@ -203,7 +204,7 @@ class FSRepo extends FileRepo { } } if ( $good ) { - chmod( $dstPath, 0644 ); + @chmod( $dstPath, $this->fileMode ); $status->successCount++; } else { $status->failCount++; @@ -389,7 +390,7 @@ class FSRepo extends FileRepo { $status->successCount++; wfDebug(__METHOD__.": wrote tempfile $srcPath to $dstPath\n"); // Thread-safe override for umask - chmod( $dstPath, 0644 ); + @chmod( $dstPath, $this->fileMode ); } else { $status->failCount++; } @@ -466,7 +467,7 @@ class FSRepo extends FileRepo { $status->error( 'filerenameerror', $srcPath, $archivePath ); $good = false; } else { - @chmod( $archivePath, 0644 ); + @chmod( $archivePath, $this->fileMode ); } } if ( $good ) { -- 2.20.1