r50313 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50312‎ | r50313 | r50314 >
Date:16:18, 7 May 2009
Author:demon
Status:resolved (Comments)
Tags:
Comment:
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
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/filerepo/FSRepo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/FSRepo.php
@@ -6,7 +6,7 @@
77 * @ingroup FileRepo
88 */
99 class FSRepo extends FileRepo {
10 - var $directory, $deletedDir, $url, $deletedHashLevels;
 10+ var $directory, $deletedDir, $url, $deletedHashLevels, $fileMode;
1111 var $fileFactory = array( 'UnregisteredLocalFile', 'newFromTitle' );
1212 var $oldFileFactory = false;
1313 var $pathDisclosureProtection = 'simple';
@@ -23,6 +23,7 @@
2424 $this->deletedHashLevels = isset( $info['deletedHashLevels'] ) ?
2525 $info['deletedHashLevels'] : $this->hashLevels;
2626 $this->deletedDir = isset( $info['deletedDir'] ) ? $info['deletedDir'] : false;
 27+ $this->fileMode = isset( $info['fileMode'] ) ? $info['fileMode'] : 0644;
2728 }
2829
2930 /**
@@ -203,7 +204,7 @@
204205 }
205206 }
206207 if ( $good ) {
207 - chmod( $dstPath, 0644 );
 208+ @chmod( $dstPath, $this->fileMode );
208209 $status->successCount++;
209210 } else {
210211 $status->failCount++;
@@ -389,7 +390,7 @@
390391 $status->successCount++;
391392 wfDebug(__METHOD__.": wrote tempfile $srcPath to $dstPath\n");
392393 // Thread-safe override for umask
393 - chmod( $dstPath, 0644 );
 394+ @chmod( $dstPath, $this->fileMode );
394395 } else {
395396 $status->failCount++;
396397 }
@@ -466,7 +467,7 @@
467468 $status->error( 'filerenameerror', $srcPath, $archivePath );
468469 $good = false;
469470 } else {
470 - @chmod( $archivePath, 0644 );
 471+ @chmod( $archivePath, $this->fileMode );
471472 }
472473 }
473474 if ( $good ) {
Index: trunk/phase3/includes/DefaultSettings.php
@@ -208,6 +208,8 @@
209209 * May be 'paranoid' to remove all parameters from error messages, 'none' to
210210 * leave the paths in unchanged, or 'simple' to replace paths with
211211 * placeholders. Default for LocalRepo is 'simple'.
 212+ * fileMode This allows wikis to set the file mode when uploading/moving files. Default
 213+ * is 0644.
212214 *
213215 * These settings describe a foreign MediaWiki installation. They are optional, and will be ignored
214216 * for local repositories:
Index: trunk/phase3/RELEASE-NOTES
@@ -22,6 +22,8 @@
2323
2424 * (bug 18222) $wgMinimalPasswordLength default is now 1
2525 * $wgSessionHandler can be used to configure session.save_handler
 26+* $wgLocalFileRepo/$wgForeignFileRepos now have a 'fileMode' parameter to
 27+ be used when uploading/moving files
2628
2729 === New features in 1.16 ===
2830
@@ -113,8 +115,8 @@
114116 * (bug 6802) profileinfo.php now also work on other database servers than MySQL
115117 * (bug 16925) Diffs no longer fail when $wgExternalDiffEngine is set to 'wikidiff'
116118 or 'wikidiff2' but extension is not installed
 119+* (bug 18326) Chmod errors in file repos have been hidden
117120
118 -
119121 == API changes in 1.16 ==
120122
121123 * Added uiprop=changeablegroups to meta=userinfo

Comments

#Comment by Tim Starling (talk | contribs)   16:21, 19 May 2009

Please don't use the error suppression operator, if there's a fatal error it'll just produce a blank page, which is almost impossible to track down when you're helping someone on IRC. And the PHP devs hate it so much that they introduced an E_STRICT error level which disables it, which we are now apparently forced to support. The correct solution is to wrap the code that issues warnings with wfSuppressWarnings()/wfRestoreWarnings().

Status & tagging log