3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
21 namespace MediaWiki\Specials
;
24 use MediaWiki\HTMLForm\HTMLForm
;
25 use MediaWiki\MainConfigNames
;
26 use MediaWiki\SpecialPage\FormSpecialPage
;
27 use MediaWiki\Status\Status
;
28 use MediaWiki\User\User
;
29 use Wikimedia\AtEase\AtEase
;
32 * Implements Special:Unlockdb
35 * @ingroup SpecialPage
37 class SpecialUnlockdb
extends FormSpecialPage
{
39 public function __construct() {
40 parent
::__construct( 'Unlockdb', 'siteadmin' );
43 public function doesWrites() {
47 public function requiresWrite() {
51 public function checkExecutePermissions( User
$user ) {
52 parent
::checkExecutePermissions( $user );
53 # If the lock file isn't writable, we can do sweet bugger all
54 if ( !file_exists( $this->getConfig()->get( MainConfigNames
::ReadOnlyFile
) ) ) {
55 throw new ErrorPageError( 'lockdb', 'databasenotlocked' );
59 protected function getFormFields() {
63 'label-message' => 'unlockconfirm',
68 protected function alterForm( HTMLForm
$form ) {
69 $form->setWrapperLegend( false )
70 ->setHeaderHtml( $this->msg( 'unlockdbtext' )->parseAsBlock() )
71 ->setSubmitTextMsg( 'unlockbtn' );
74 public function onSubmit( array $data ) {
75 if ( !$data['Confirm'] ) {
76 return Status
::newFatal( 'locknoconfirm' );
79 $readOnlyFile = $this->getConfig()->get( MainConfigNames
::ReadOnlyFile
);
80 AtEase
::suppressWarnings();
81 $res = unlink( $readOnlyFile );
82 AtEase
::restoreWarnings();
85 return Status
::newGood();
87 return Status
::newFatal( 'filedeleteerror', $readOnlyFile );
91 public function onSuccess() {
92 $out = $this->getOutput();
93 $out->addSubtitle( $this->msg( 'unlockdbsuccesssub' ) );
94 $out->addWikiMsg( 'unlockdbsuccesstext' );
97 protected function getDisplayFormat() {
101 protected function getGroupName() {
107 * Retain the old class name for backwards compatibility.
108 * @deprecated since 1.41
110 class_alias( SpecialUnlockdb
::class, 'SpecialUnlockdb' );