61 parent::__construct( $mainModule, $moduleName );
65 $this->watchlistMaxDuration =
67 $this->watchlistManager = $watchlistManager;
68 $this->userOptionsLookup = $userOptionsLookup;
69 $this->undeletePageFactory = $undeletePageFactory;
70 $this->wikiPageFactory = $wikiPageFactory;
79 $block = $user->getBlock( IDBAccessObject::READ_LATEST );
80 if ( $block && $block->isSitewide() ) {
84 $titleObj = Title::newFromText(
$params[
'title'] );
85 if ( !$titleObj || $titleObj->isExternal() ) {
88 if ( !$titleObj->canExist() ) {
93 if ( !isset(
$params[
'timestamps'] ) ) {
96 if ( !is_array(
$params[
'timestamps'] ) ) {
99 foreach (
$params[
'timestamps'] as $i => $ts ) {
103 $undeletePage = $this->undeletePageFactory->newUndeletePage(
104 $this->wikiPageFactory->newFromTitle( $titleObj ),
105 $this->getAuthority()
107 ->setUndeleteOnlyTimestamps(
$params[
'timestamps'] ?? [] )
108 ->setUndeleteOnlyFileVersions(
$params[
'fileids'] ?: [] )
109 ->setTags(
$params[
'tags'] ?: [] );
111 if (
$params[
'undeletetalk'] ) {
112 $undeletePage->setUndeleteAssociatedTalk(
true );
115 $status = $undeletePage->undeleteIfAllowed(
$params[
'reason'] );
116 if ( $status->isOK() ) {
126 if ( $restoredRevs === 0 && $restoredFiles === 0 ) {
131 if ( $restoredFiles ) {
138 $this->
setWatch(
$params[
'watchlist'], $titleObj, $user,
null, $watchlistExpiry );
141 'title' => $titleObj->getPrefixedText(),
142 'revisions' => $restoredRevs,
143 'fileversions' => $restoredFiles,
160 ParamValidator::PARAM_TYPE =>
'string',
161 ParamValidator::PARAM_REQUIRED => true
165 ParamValidator::PARAM_TYPE =>
'tags',
166 ParamValidator::PARAM_ISMULTI =>
true,
169 ParamValidator::PARAM_TYPE =>
'timestamp',
170 ParamValidator::PARAM_ISMULTI =>
true,
173 ParamValidator::PARAM_TYPE =>
'integer',
174 ParamValidator::PARAM_ISMULTI =>
true,
176 'undeletetalk' =>
false,
185 $title = Title::newMainPage()->getPrefixedText();
186 $mp = rawurlencode( $title );
189 "action=undelete&title={$mp}&token=123ABC&reason=Restoring%20{$mp}"
190 =>
'apihelp-undelete-example-page',
191 "action=undelete&title={$mp}&token=123ABC" .
192 '×tamps=2007-07-03T22:00:45Z|2007-07-02T19:48:56Z'
193 =>
'apihelp-undelete-example-revisions',
198 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Undelete';
203class_alias( ApiUndelete::class,
'ApiUndelete' );
wfEscapeWikiText( $input)
Escapes the given text so that it may be output using addWikiText() without any linking,...
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
array $params
The job parameters.
This is the main API class, used for both external and internal processing.
A class containing constants representing the names of configuration variables.
const WatchlistExpiry
Name constant for the WatchlistExpiry setting, for use with Config::get()
const WatchlistExpiryMaxDuration
Name constant for the WatchlistExpiryMaxDuration setting, for use with Config::get()
Backend logic for performing a page undelete action.
Service for creating WikiPage objects.
trait ApiWatchlistTrait
An ApiWatchlistTrait adds class properties and convenience methods for APIs that allow you to watch a...
Service for page undelete actions.