53 parent::__construct( $mainModule, $moduleName );
57 $this->watchlistMaxDuration =
59 $this->watchlistManager = $watchlistManager;
60 $this->userOptionsLookup = $userOptionsLookup;
61 $this->undeletePageFactory = $undeletePageFactory;
62 $this->wikiPageFactory = $wikiPageFactory;
71 $block = $user->getBlock( IDBAccessObject::READ_LATEST );
72 if ( $block && $block->isSitewide() ) {
76 $titleObj = Title::newFromText( $params[
'title'] );
77 if ( !$titleObj || $titleObj->isExternal() ) {
80 if ( !$titleObj->canExist() ) {
85 if ( !isset( $params[
'timestamps'] ) ) {
86 $params[
'timestamps'] = [];
88 if ( !is_array( $params[
'timestamps'] ) ) {
89 $params[
'timestamps'] = [ $params[
'timestamps'] ];
91 foreach ( $params[
'timestamps'] as $i => $ts ) {
92 $params[
'timestamps'][$i] =
wfTimestamp( TS_MW, $ts );
95 $undeletePage = $this->undeletePageFactory->newUndeletePage(
96 $this->wikiPageFactory->newFromTitle( $titleObj ),
99 ->setUndeleteOnlyTimestamps( $params[
'timestamps'] ?? [] )
100 ->setUndeleteOnlyFileVersions( $params[
'fileids'] ?: [] )
101 ->setTags( $params[
'tags'] ?: [] );
103 if ( $params[
'undeletetalk'] ) {
104 $undeletePage->setUndeleteAssociatedTalk(
true );
107 $status = $undeletePage->undeleteIfAllowed( $params[
'reason'] );
108 if ( $status->isOK() ) {
118 if ( $restoredRevs === 0 && $restoredFiles === 0 ) {
123 if ( $restoredFiles ) {
125 $titleObj, $params[
'fileids'],
126 $this->
getUser(), $params[
'reason'] );
130 $this->
setWatch( $params[
'watchlist'], $titleObj, $user,
null, $watchlistExpiry );
133 'title' => $titleObj->getPrefixedText(),
134 'revisions' => $restoredRevs,
135 'fileversions' => $restoredFiles,
136 'reason' => $params[
'reason']
152 ParamValidator::PARAM_TYPE =>
'string',
153 ParamValidator::PARAM_REQUIRED => true
157 ParamValidator::PARAM_TYPE =>
'tags',
158 ParamValidator::PARAM_ISMULTI =>
true,
161 ParamValidator::PARAM_TYPE =>
'timestamp',
162 ParamValidator::PARAM_ISMULTI =>
true,
165 ParamValidator::PARAM_TYPE =>
'integer',
166 ParamValidator::PARAM_ISMULTI =>
true,
168 'undeletetalk' =>
false,
177 $title = Title::newMainPage()->getPrefixedText();
178 $mp = rawurlencode( $title );
181 "action=undelete&title={$mp}&token=123ABC&reason=Restoring%20{$mp}"
182 =>
'apihelp-undelete-example-page',
183 "action=undelete&title={$mp}&token=123ABC" .
184 '×tamps=2007-07-03T22:00:45Z|2007-07-02T19:48:56Z'
185 =>
'apihelp-undelete-example-revisions',
190 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Undelete';
195class_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.
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.