Index: trunk/phase3/includes/SpecialLockdb.php |
— | — | @@ -15,6 +15,13 @@ |
16 | 16 | $wgOut->permissionRequired( 'siteadmin' ); |
17 | 17 | return; |
18 | 18 | } |
| 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 | + } |
19 | 26 | |
20 | 27 | $action = $wgRequest->getVal( 'action' ); |
21 | 28 | $f = new DBLockForm(); |
— | — | @@ -92,10 +99,13 @@ |
93 | 100 | $this->showForm( wfMsg( 'locknoconfirm' ) ); |
94 | 101 | return; |
95 | 102 | } |
96 | | - $fp = fopen( $wgReadOnlyFile, 'w' ); |
| 103 | + $fp = @fopen( $wgReadOnlyFile, 'w' ); |
97 | 104 | |
98 | 105 | 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(); |
100 | 110 | return; |
101 | 111 | } |
102 | 112 | fwrite( $fp, $this->reason ); |
— | — | @@ -114,6 +124,12 @@ |
115 | 125 | $wgOut->setSubtitle( wfMsg( 'lockdbsuccesssub' ) ); |
116 | 126 | $wgOut->addWikiText( wfMsg( 'lockdbsuccesstext' ) ); |
117 | 127 | } |
| 128 | + |
| 129 | + function notWritable() { |
| 130 | + global $wgOut; |
| 131 | + $wgOut->errorPage( 'lockdb', 'lockfilenotwritable' ); |
| 132 | + } |
| 133 | + |
118 | 134 | } |
119 | 135 | |
120 | 136 | ?> |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -42,6 +42,7 @@ |
43 | 43 | the presence of large numbers of blocks; added indexes and implemented an |
44 | 44 | indexed pager. |
45 | 45 | * (bug 6448) Allow filtering of Special:Newpages according to username |
| 46 | +* (bug 6618) Improve permissions/error detection in Special:Lockdb |
46 | 47 | |
47 | 48 | == Languages updated == |
48 | 49 | |
Index: trunk/phase3/languages/Messages.php |
— | — | @@ -1344,6 +1344,7 @@ |
1345 | 1345 | 'lockdbsuccesstext' => 'The database has been locked. |
1346 | 1346 | <br />Remember to remove the lock after your maintenance is complete.', |
1347 | 1347 | '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.', |
1348 | 1349 | |
1349 | 1350 | # Make sysop |
1350 | 1351 | 'makesysoptitle' => 'Make a user into a sysop', |