3 * Implements Special:Unlockdb
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @ingroup SpecialPage
25 * Implements Special:Unlockdb
27 * @ingroup SpecialPage
29 class SpecialUnlockdb
extends FormSpecialPage
{
31 public function __construct() {
32 parent
::__construct( 'Unlockdb', 'siteadmin' );
35 public function doesWrites() {
39 public function requiresWrite() {
43 public function checkExecutePermissions( User
$user ) {
44 parent
::checkExecutePermissions( $user );
45 # If the lock file isn't writable, we can do sweet bugger all
46 if ( !file_exists( $this->getConfig()->get( 'ReadOnlyFile' ) ) ) {
47 throw new ErrorPageError( 'lockdb', 'databasenotlocked' );
51 protected function getFormFields() {
55 'label-message' => 'unlockconfirm',
60 protected function alterForm( HTMLForm
$form ) {
61 $form->setWrapperLegend( false )
62 ->setHeaderText( $this->msg( 'unlockdbtext' )->parseAsBlock() )
63 ->setSubmitTextMsg( 'unlockbtn' );
66 public function onSubmit( array $data ) {
67 if ( !$data['Confirm'] ) {
68 return Status
::newFatal( 'locknoconfirm' );
71 $readOnlyFile = $this->getConfig()->get( 'ReadOnlyFile' );
72 MediaWiki\
suppressWarnings();
73 $res = unlink( $readOnlyFile );
74 MediaWiki\restoreWarnings
();
77 return Status
::newGood();
79 return Status
::newFatal( 'filedeleteerror', $readOnlyFile );
83 public function onSuccess() {
84 $out = $this->getOutput();
85 $out->addSubtitle( $this->msg( 'unlockdbsuccesssub' ) );
86 $out->addWikiMsg( 'unlockdbsuccesstext' );
89 protected function getDisplayFormat() {
93 protected function getGroupName() {