2007-06-03 15:18:33 +00:00
|
|
|
<?php
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
/**
|
2008-07-19 12:15:07 +00:00
|
|
|
* Undelete a page by fetching it from the archive table
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
*
|
2010-12-16 19:15:12 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @file
|
|
|
|
|
* @ingroup Maintenance
|
|
|
|
|
*/
|
2007-06-03 15:18:33 +00:00
|
|
|
|
2023-03-01 20:33:26 +00:00
|
|
|
use MediaWiki\Title\Title;
|
2023-09-19 12:13:45 +00:00
|
|
|
use MediaWiki\User\User;
|
2022-10-25 16:58:49 +00:00
|
|
|
|
2024-08-27 12:00:25 +00:00
|
|
|
// @codeCoverageIgnoreStart
|
2013-05-17 00:16:59 +00:00
|
|
|
require_once __DIR__ . '/Maintenance.php';
|
2024-08-27 12:00:25 +00:00
|
|
|
// @codeCoverageIgnoreEnd
|
2007-06-03 15:18:33 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
class Undelete extends Maintenance {
|
|
|
|
|
public function __construct() {
|
|
|
|
|
parent::__construct();
|
2016-01-30 02:48:47 +00:00
|
|
|
$this->addDescription( 'Undelete a page' );
|
2011-04-14 19:01:04 +00:00
|
|
|
$this->addOption( 'user', 'The user to perform the undeletion', false, true, 'u' );
|
|
|
|
|
$this->addOption( 'reason', 'The reason to undelete', false, true, 'r' );
|
2009-08-18 23:06:24 +00:00
|
|
|
$this->addArg( 'pagename', 'Page to undelete' );
|
2009-08-02 19:35:17 +00:00
|
|
|
}
|
2007-06-03 15:18:33 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
public function execute() {
|
2020-06-05 01:37:01 +00:00
|
|
|
$username = $this->getOption( 'user', false );
|
2011-04-14 19:01:04 +00:00
|
|
|
$reason = $this->getOption( 'reason', '' );
|
2019-02-28 11:13:49 +00:00
|
|
|
$pageName = $this->getArg( 0 );
|
2007-06-03 15:18:33 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
$title = Title::newFromText( $pageName );
|
|
|
|
|
if ( !$title ) {
|
2017-11-20 00:36:54 +00:00
|
|
|
$this->fatalError( "Invalid title" );
|
2009-08-02 19:35:17 +00:00
|
|
|
}
|
2020-06-05 01:37:01 +00:00
|
|
|
if ( $username === false ) {
|
|
|
|
|
$user = User::newSystemUser( 'Command line script', [ 'steal' => true ] );
|
2015-09-04 16:17:42 +00:00
|
|
|
} else {
|
2020-06-05 01:37:01 +00:00
|
|
|
$user = User::newFromName( $username );
|
2015-09-04 16:17:42 +00:00
|
|
|
}
|
2020-06-05 01:37:01 +00:00
|
|
|
if ( !$user ) {
|
2017-11-20 00:36:54 +00:00
|
|
|
$this->fatalError( "Invalid username" );
|
2011-11-20 10:55:58 +00:00
|
|
|
}
|
2020-06-05 01:37:01 +00:00
|
|
|
|
2024-07-21 07:59:11 +00:00
|
|
|
$page = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $title );
|
|
|
|
|
$this->output( "Undeleting " . $title->getPrefixedDBkey() . "...\n" );
|
|
|
|
|
|
|
|
|
|
$status = $this->getServiceContainer()->getUndeletePageFactory()
|
|
|
|
|
->newUndeletePage( $page, $user )
|
|
|
|
|
->undeleteUnsafe( $reason );
|
|
|
|
|
if ( !$status->isGood() ) {
|
|
|
|
|
$this->fatalError( $status );
|
|
|
|
|
}
|
2009-08-02 19:35:17 +00:00
|
|
|
$this->output( "done\n" );
|
|
|
|
|
}
|
2007-06-03 15:18:33 +00:00
|
|
|
}
|
2007-06-29 01:19:14 +00:00
|
|
|
|
2024-08-27 12:00:25 +00:00
|
|
|
// @codeCoverageIgnoreStart
|
2018-01-13 00:02:09 +00:00
|
|
|
$maintClass = Undelete::class;
|
2013-05-07 23:00:15 +00:00
|
|
|
require_once RUN_MAINTENANCE_IF_MAIN;
|
2024-08-27 12:00:25 +00:00
|
|
|
// @codeCoverageIgnoreEnd
|