43 $titleObj = $pageObj->getTitle();
44 if ( !$pageObj->exists() &&
46 !( $titleObj->getNamespace() ==
NS_FILE && self::canDeleteFile( $pageObj->getFile() ) )
51 $reason = $params[
'reason'];
59 if ( $params[
'tags'] ) {
61 if ( !$tagStatus->isOK() ) {
66 if ( $titleObj->getNamespace() ==
NS_FILE ) {
76 $status =
self::delete( $pageObj, $user, $reason, $params[
'tags'] );
79 if ( !$status->isOK() ) {
85 if ( $params[
'watch'] ) {
87 } elseif ( $params[
'unwatch'] ) {
90 $watch = $params[
'watchlist'];
92 $this->
setWatch( $watch, $titleObj,
'watchdeletion' );
95 'title' => $titleObj->getPrefixedText(),
98 if ( $status->hasMessage(
'delete-scheduled' ) ) {
99 $r[
'scheduled'] =
true;
101 if ( $status->value !==
null ) {
103 $r[
'logid'] = $status->value;
117 protected static function delete(
Page $page,
User $user, &$reason =
null, $tags = [] ) {
118 $title = $page->getTitle();
121 if ( is_null( $reason ) ) {
125 $reason = $page->getAutoDeleteReason( $hasHistory );
126 if ( $reason ===
false ) {
128 return Status::newFatal(
'cannotdelete',
$title->getPrefixedText() );
135 return $page->doDeleteArticleReal( $reason,
false, 0,
true, $error, $user, $tags );
156 &$reason =
null, $suppress =
false, $tags = []
158 $title = $page->getTitle();
161 $file = $page->getFile();
162 if ( !self::canDeleteFile(
$file ) ) {
168 return Status::newFatal(
'invalidoldimage' );
170 $oldfile = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName(
$title, $oldimage );
171 if ( !$oldfile->exists() || !$oldfile->isLocal() || $oldfile->getRedirected() ) {
172 return Status::newFatal(
'nodeleteablefile' );
176 if ( is_null( $reason ) ) {
229 'action=delete&title=Main%20Page&token=123ABC'
230 =>
'apihelp-delete-example-simple',
231 'action=delete&title=Main%20Page&token=123ABC&reason=Preparing%20for%20move'
232 =>
'apihelp-delete-example-reason',
237 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Delete';
This abstract class implements many basic API functions, and is the base of all API classes.
const PARAM_DEPRECATED
(boolean) Is the parameter deprecated (will show a warning)?
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
checkTitleUserPermissions(LinkTarget $linkTarget, $actions, $options=[])
Helper function for permission-denied errors.
addMessagesFromStatus(StatusValue $status, $types=[ 'warning', 'error'], array $filter=[])
Add warnings and/or errors from a Status.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
setWatch( $watch, $titleObj, $userOption=null)
Set a watch (or unwatch) based the based on a watchlist parameter.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
getModuleName()
Get the name of the module being executed by this instance.
getTitleOrPageId( $params, $load=false)
Get a WikiPage object from a title or pageid param, if possible.
dieStatus(StatusValue $status)
Throw an ApiUsageException based on the Status object.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
API module that facilitates deleting pages.
execute()
Extracts the title and reason from the request parameters and invokes the local delete() function wit...
needsToken()
Returns the token type this module requires in order to execute.
getExamplesMessages()
Returns usage examples for this module.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getHelpUrls()
Return links to more detailed help pages about the module.
static canDeleteFile(File $file)
isWriteMode()
Indicates whether this module requires write mode.
static deleteFile(Page $page, User $user, $oldimage, &$reason=null, $suppress=false, $tags=[])
static delete(Page $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.
Implements some public methods and some protected utility functions which are required by multiple ch...
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Interface for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.