r15490 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r15489‎ | r15490 | r15491 >
Date:08:53, 10 July 2006
Author:robchurch
Status:old
Tags:
Comment:
* (bug 6618) Improve permissions/error detection in Special:Lockdb
* Add another explicit check
* Suppress errors on the fopen()
* If the fopen() fails, assume a permissions problem
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialLockdb.php (modified) (history)
  • /trunk/phase3/languages/Messages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialLockdb.php
@@ -15,6 +15,13 @@
1616 $wgOut->permissionRequired( 'siteadmin' );
1717 return;
1818 }
 19+
 20+ # If the lock file isn't writable, we can do sweet bugger all
 21+ global $wgReadOnlyFile;
 22+ if( !is_writable( dirname( $wgReadOnlyFile ) ) ) {
 23+ DBLockForm::notWritable();
 24+ return;
 25+ }
1926
2027 $action = $wgRequest->getVal( 'action' );
2128 $f = new DBLockForm();
@@ -92,10 +99,13 @@
93100 $this->showForm( wfMsg( 'locknoconfirm' ) );
94101 return;
95102 }
96 - $fp = fopen( $wgReadOnlyFile, 'w' );
 103+ $fp = @fopen( $wgReadOnlyFile, 'w' );
97104
98105 if ( false === $fp ) {
99 - $wgOut->showFileNotFoundError( $wgReadOnlyFile );
 106+ # This used to show a file not found error, but the likeliest reason for fopen()
 107+ # to fail at this point is insufficient permission to write to the file...good old
 108+ # is_writable() is plain wrong in some cases, it seems...
 109+ $this->notWritable();
100110 return;
101111 }
102112 fwrite( $fp, $this->reason );
@@ -114,6 +124,12 @@
115125 $wgOut->setSubtitle( wfMsg( 'lockdbsuccesssub' ) );
116126 $wgOut->addWikiText( wfMsg( 'lockdbsuccesstext' ) );
117127 }
 128+
 129+ function notWritable() {
 130+ global $wgOut;
 131+ $wgOut->errorPage( 'lockdb', 'lockfilenotwritable' );
 132+ }
 133+
118134 }
119135
120136 ?>
Index: trunk/phase3/RELEASE-NOTES
@@ -42,6 +42,7 @@
4343 the presence of large numbers of blocks; added indexes and implemented an
4444 indexed pager.
4545 * (bug 6448) Allow filtering of Special:Newpages according to username
 46+* (bug 6618) Improve permissions/error detection in Special:Lockdb
4647
4748 == Languages updated ==
4849
Index: trunk/phase3/languages/Messages.php
@@ -1344,6 +1344,7 @@
13451345 'lockdbsuccesstext' => 'The database has been locked.
13461346 <br />Remember to remove the lock after your maintenance is complete.',
13471347 'unlockdbsuccesstext' => 'The database has been unlocked.',
 1348+'lockfilenotwritable' => 'The database lock file is not writable. To lock or unlock the database, this needs to be writable by the web server.',
13481349
13491350 # Make sysop
13501351 'makesysoptitle' => 'Make a user into a sysop',