Go to the documentation of this file.
43 $titleObj = $pageObj->getTitle();
44 if ( !$pageObj->exists() &&
51 $reason = $params[
'reason'];
59 if ( $params[
'tags'] ) {
61 if ( !$tagStatus->isOK() ) {
66 if ( $titleObj->getNamespace() ==
NS_FILE ) {
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 ) {
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 ) {
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 ) ) {
171 if ( !$oldfile->exists() || !$oldfile->isLocal() || $oldfile->getRedirected() ) {
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';
Interface for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)
static newFatal( $message,... $parameters)
Factory function for fatal errors.
static deleteFile(Page $page, User $user, $oldimage, &$reason=null, $suppress=false, $tags=[])
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.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
getResult()
Get the result object.
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)
checkTitleUserPermissions(LinkTarget $linkTarget, $actions, $options=[])
Helper function for permission-denied errors.
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)?
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.
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...
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
setWatch( $watch, $titleObj, $userOption=null)
Set a watch (or unwatch) based the based on a watchlist parameter.
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.
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.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
dieStatus(StatusValue $status)
Throw an ApiUsageException based on the Status object.
getModuleName()
Get the name of the module being executed by this instance.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
isWriteMode()
Indicates whether this module requires write mode.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...