Go to the documentation of this file.
36 parent::__construct( $mainModule, $moduleName, $modulePrefix );
38 $this->watchlistExpiryEnabled = $this->
getConfig()->get(
'WatchlistExpiry' );
39 $this->watchlistMaxDuration = $this->
getConfig()->get(
'WatchlistExpiryMaxDuration' );
55 $titleObj = $pageObj->getTitle();
56 if ( !$pageObj->exists() &&
58 !( $titleObj->getNamespace() ===
NS_FILE && self::canDeleteFile( $pageObj->getFile() ) )
63 $reason = $params[
'reason'];
71 if ( $params[
'tags'] ) {
73 if ( !$tagStatus->isOK() ) {
78 if ( $titleObj->getNamespace() ===
NS_FILE ) {
88 $status =
self::delete( $pageObj, $user, $reason, $params[
'tags'] );
91 if ( !$status->isOK() ) {
97 if ( $params[
'watch'] ) {
99 } elseif ( $params[
'unwatch'] ) {
102 $watch = $params[
'watchlist'];
106 $this->
setWatch( $watch, $titleObj, $user,
'watchdeletion', $watchlistExpiry );
109 'title' => $titleObj->getPrefixedText(),
113 if ( $status->hasMessage(
'delete-scheduled' ) ) {
114 $r[
'scheduled'] =
true;
116 if ( $status->value !==
null ) {
118 $r[
'logid'] = $status->value;
132 private static function delete(
WikiPage $page,
User $user, &$reason =
null, $tags = [] ) {
136 if ( $reason ===
null ) {
141 if ( $reason ===
false ) {
179 &$reason =
null, $suppress =
false, $tags = []
184 $file = $page->getFile();
185 if ( !self::canDeleteFile(
$file ) ) {
193 $oldfile = MediaWikiServices::getInstance()->getRepoGroup()
194 ->getLocalRepo()->newFromArchiveName(
$title, $oldimage );
195 if ( !$oldfile->exists() || !$oldfile->isLocal() || $oldfile->getRedirected() ) {
200 if ( $reason ===
null ) {
251 'action=delete&title=Main%20Page&token=123ABC'
252 =>
'apihelp-delete-example-simple',
253 'action=delete&title=Main%20Page&token=123ABC&reason=Preparing%20for%20move'
254 =>
'apihelp-delete-example-reason',
259 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Delete';
checkTitleUserPermissions( $pageIdentity, $actions, array $options=[])
Helper function for permission-denied errors.
This is the main API class, used for both external and internal processing.
getAutoDeleteReason(&$hasHistory)
Auto-generates a deletion reason.
getExpiryFromParams(array $params)
Get formatted expiry from the given parameters, or null if no expiry was provided.
static newFatal( $message,... $parameters)
Factory function for fatal errors.
__construct(ApiMain $mainModule, $moduleName, $modulePrefix='')
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
getTitleOrPageId( $params, $load=false)
Get a WikiPage object from a title or pageid param, if possible.
getResult()
Get the result object.
Class representing a MediaWiki article and history.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
addMessagesFromStatus(StatusValue $status, $types=[ 'warning', 'error'], array $filter=[])
Add warnings and/or errors from a Status.
static canDeleteFile(File $file)
This abstract class implements many basic API functions, and is the base of all API classes.
needsToken()
Returns the token type this module requires in order to execute.
Implements some public methods and some protected utility functions which are required by multiple ch...
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
API module that facilitates deleting pages.
static delete(WikiPage $page, User $user, &$reason=null, $tags=[])
We have our own delete() function, since Article.php's implementation is split in two phases.
mustBePosted()
Indicates whether this module must be called with a POST request.
execute()
Extracts the title and reason from the request parameters and invokes the local delete() function wit...
setWatch(string $watch, Title $title, User $user, ?string $userOption=null, ?string $expiry=null)
Set a watch (or unwatch) based the based on a watchlist parameter.
getTitle()
Get the title object of the article.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
doDeleteArticleReal( $reason, UserIdentity $deleter, $suppress=false, $u1=null, &$error='', $u2=null, $tags=[], $logsubtype='delete', $immediate=false)
Back-end article deletion Deletes the article with database consistency, writes logs,...
getExamplesMessages()
Returns usage examples for this module.
getHelpUrls()
Return links to more detailed help pages about the module.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
trait ApiWatchlistTrait
An ApiWatchlistTrait adds class properties and convenience methods for APIs that allow you to watch a...
static deleteFile(WikiPage $page, User $user, $oldimage, &$reason=null, $suppress=false, $tags=[])
getWatchlistParams(array $watchOptions=[])
Get additional allow params specific to watchlisting.
dieStatus(StatusValue $status)
Throw an ApiUsageException based on the Status object.
getModuleName()
Get the name of the module being executed by this instance.
isWriteMode()
Indicates whether this module requires write mode.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...