dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
(bug 11562) API: Added a user_registration parameter/field to the list=allusers query...
[lhc/web/wiklou.git]
/
includes
/
SpecialLockdb.php
diff --git
a/includes/SpecialLockdb.php
b/includes/SpecialLockdb.php
index
ee72c65
..
e57717e
100644
(file)
--- a/
includes/SpecialLockdb.php
+++ b/
includes/SpecialLockdb.php
@@
-1,8
+1,7
@@
<?php
/**
*
<?php
/**
*
- * @package MediaWiki
- * @subpackage SpecialPage
+ * @addtogroup SpecialPage
*/
/**
*/
/**
@@
-15,6
+14,13
@@
function wfSpecialLockdb() {
$wgOut->permissionRequired( 'siteadmin' );
return;
}
$wgOut->permissionRequired( 'siteadmin' );
return;
}
+
+ # If the lock file isn't writable, we can do sweet bugger all
+ global $wgReadOnlyFile;
+ if( !is_writable( dirname( $wgReadOnlyFile ) ) ) {
+ DBLockForm::notWritable();
+ return;
+ }
$action = $wgRequest->getVal( 'action' );
$f = new DBLockForm();
$action = $wgRequest->getVal( 'action' );
$f = new DBLockForm();
@@
-30,9
+36,8
@@
function wfSpecialLockdb() {
}
/**
}
/**
- *
- * @package MediaWiki
- * @subpackage SpecialPage
+ * A form to make the database readonly (eg for maintenance purposes).
+ * @addtogroup SpecialPage
*/
class DBLockForm {
var $reason = '';
*/
class DBLockForm {
var $reason = '';
@@
-55,14
+60,15
@@
class DBLockForm {
$lc = htmlspecialchars( wfMsg( 'lockconfirm' ) );
$lb = htmlspecialchars( wfMsg( 'lockbtn' ) );
$elr = htmlspecialchars( wfMsg( 'enterlockreason' ) );
$lc = htmlspecialchars( wfMsg( 'lockconfirm' ) );
$lb = htmlspecialchars( wfMsg( 'lockbtn' ) );
$elr = htmlspecialchars( wfMsg( 'enterlockreason' ) );
- $titleObj =
Title::makeTitle( NS_SPECIAL,
'Lockdb' );
+ $titleObj =
SpecialPage::getTitleFor(
'Lockdb' );
$action = $titleObj->escapeLocalURL( 'action=submit' );
$action = $titleObj->escapeLocalURL( 'action=submit' );
+ $reason = htmlspecialchars( $this->reason );
$token = htmlspecialchars( $wgUser->editToken() );
$wgOut->addHTML( <<<END
<form id="lockdb" method="post" action="{$action}">
{$elr}:
$token = htmlspecialchars( $wgUser->editToken() );
$wgOut->addHTML( <<<END
<form id="lockdb" method="post" action="{$action}">
{$elr}:
-<textarea name="wpLockReason" rows="10" cols="60" wrap="virtual"></textarea>
+<textarea name="wpLockReason" rows="10" cols="60" wrap="virtual">
{$reason}
</textarea>
<table border="0">
<tr>
<td align="right">
<table border="0">
<tr>
<td align="right">
@@
-92,10
+98,13
@@
END
$this->showForm( wfMsg( 'locknoconfirm' ) );
return;
}
$this->showForm( wfMsg( 'locknoconfirm' ) );
return;
}
- $fp = fopen( $wgReadOnlyFile, 'w' );
+ $fp =
@
fopen( $wgReadOnlyFile, 'w' );
if ( false === $fp ) {
if ( false === $fp ) {
- $wgOut->showFileNotFoundError( $wgReadOnlyFile );
+ # This used to show a file not found error, but the likeliest reason for fopen()
+ # to fail at this point is insufficient permission to write to the file...good old
+ # is_writable() is plain wrong in some cases, it seems...
+ $this->notWritable();
return;
}
fwrite( $fp, $this->reason );
return;
}
fwrite( $fp, $this->reason );
@@
-103,7
+112,7
@@
END
$wgLang->timeanddate( wfTimestampNow() ) . ")\n" );
fclose( $fp );
$wgLang->timeanddate( wfTimestampNow() ) . ")\n" );
fclose( $fp );
- $titleObj =
Title::makeTitle( NS_SPECIAL,
'Lockdb' );
+ $titleObj =
SpecialPage::getTitleFor(
'Lockdb' );
$wgOut->redirect( $titleObj->getFullURL( 'action=success' ) );
}
$wgOut->redirect( $titleObj->getFullURL( 'action=success' ) );
}
@@
-114,6
+123,12
@@
END
$wgOut->setSubtitle( wfMsg( 'lockdbsuccesssub' ) );
$wgOut->addWikiText( wfMsg( 'lockdbsuccesstext' ) );
}
$wgOut->setSubtitle( wfMsg( 'lockdbsuccesssub' ) );
$wgOut->addWikiText( wfMsg( 'lockdbsuccesstext' ) );
}
+
+ public static function notWritable() {
+ global $wgOut;
+ $wgOut->errorPage( 'lockdb', 'lockfilenotwritable' );
+ }
+
}
}
-?>
+