X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialLockdb.php;h=c7c45b5510794bfc56f86363efe94eb44618f3bf;hb=b60a756e3068d51c790b9170b3a259a8802d0580;hp=a229fa34f4511bc698b766a6d29c47875ab6e12e;hpb=6e9b4f0e9ce4ccd6089c18b205065ef7fa077484;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialLockdb.php b/includes/specials/SpecialLockdb.php index a229fa34f4..c7c45b5510 100644 --- a/includes/specials/SpecialLockdb.php +++ b/includes/specials/SpecialLockdb.php @@ -21,6 +21,8 @@ * @ingroup SpecialPage */ +use MediaWiki\MediaWikiServices; + /** * A form to make the database readonly (eg for maintenance purposes). * @@ -34,7 +36,7 @@ class SpecialLockdb extends FormSpecialPage { } public function doesWrites() { - return true; + return false; } public function requiresWrite() { @@ -47,6 +49,9 @@ class SpecialLockdb extends FormSpecialPage { if ( !is_writable( dirname( $this->getConfig()->get( 'ReadOnlyFile' ) ) ) ) { throw new ErrorPageError( 'lockdb', 'lockfilenotwritable' ); } + if ( file_exists( $this->getConfig()->get( 'ReadOnlyFile' ) ) ) { + throw new ErrorPageError( 'lockdb', 'databaselocked' ); + } } protected function getFormFields() { @@ -65,23 +70,21 @@ class SpecialLockdb extends FormSpecialPage { } protected function alterForm( HTMLForm $form ) { - $form->setWrapperLegend( false ); - $form->setHeaderText( $this->msg( 'lockdbtext' )->parseAsBlock() ); - $form->setSubmitTextMsg( 'lockbtn' ); + $form->setWrapperLegend( false ) + ->setHeaderText( $this->msg( 'lockdbtext' )->parseAsBlock() ) + ->setSubmitTextMsg( 'lockbtn' ); } public function onSubmit( array $data ) { - global $wgContLang; - if ( !$data['Confirm'] ) { return Status::newFatal( 'locknoconfirm' ); } - MediaWiki\suppressWarnings(); + Wikimedia\suppressWarnings(); $fp = fopen( $this->getConfig()->get( 'ReadOnlyFile' ), 'w' ); - MediaWiki\restoreWarnings(); + Wikimedia\restoreWarnings(); - if ( false === $fp ) { + if ( $fp === false ) { # 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... @@ -89,10 +92,11 @@ class SpecialLockdb extends FormSpecialPage { } fwrite( $fp, $data['Reason'] ); $timestamp = wfTimestampNow(); + $contLang = MediaWikiServices::getInstance()->getContentLanguage(); fwrite( $fp, "\n

" . $this->msg( 'lockedbyandtime', $this->getUser()->getName(), - $wgContLang->date( $timestamp, false, false ), - $wgContLang->time( $timestamp, false, false ) + $contLang->date( $timestamp, false, false ), + $contLang->time( $timestamp, false, false ) )->inContentLanguage()->text() . "

\n" ); fclose( $fp ); @@ -105,6 +109,10 @@ class SpecialLockdb extends FormSpecialPage { $out->addWikiMsg( 'lockdbsuccesstext' ); } + protected function getDisplayFormat() { + return 'ooui'; + } + protected function getGroupName() { return 'wiki'; }