Go to the documentation of this file.
45 if ( !$pageObj->exists() ) {
49 $titleObj = $pageObj->getTitle();
53 if ( $titleObj->getNamespace() ==
NS_FILE ) {
66 if ( is_array( $status ) ) {
69 if ( !$status->isGood() ) {
76 } elseif (
$params[
'unwatch'] ) {
81 $this->
setWatch( $watch, $titleObj,
'watchdeletion' );
84 'title' => $titleObj->getPrefixedText(),
86 'logid' => $status->value
99 return $title->getUserPermissionsErrors(
'delete',
$user );
111 public static function delete(
Page $page,
User $user, $token, &$reason = null ) {
112 $title = $page->getTitle();
114 if ( count( $errors ) ) {
119 if ( is_null( $reason ) ) {
123 $reason = $page->getAutoDeleteReason( $hasHistory );
124 if ( $reason ===
false ) {
132 return $page->doDeleteArticleReal( $reason,
false, 0,
true,
$error );
145 &$reason =
null, $suppress =
false
147 $title = $page->getTitle();
149 if ( count( $errors ) ) {
153 $file = $page->getFile();
154 if ( !
$file->exists() || !
$file->isLocal() ||
$file->getRedirected() ) {
163 if ( !$oldfile->exists() || !$oldfile->isLocal() || $oldfile->getRedirected() ) {
168 if ( is_null( $reason ) ) {
198 'watchlist' =>
array(
219 'title' =>
"Title of the page you want to delete. Cannot be used together with {$p}pageid",
220 'pageid' =>
"Page ID of the page you want to delete. Cannot be used together with {$p}title",
221 'token' =>
'A delete token previously retrieved through prop=info',
223 =>
'Reason for the deletion. If not set, an automatically generated reason will be used',
224 'watch' =>
'Add the page to your watchlist',
225 'watchlist' =>
'Unconditionally add or remove the page from your ' .
226 'watchlist, use preferences or do not change watch',
227 'unwatch' =>
'Remove the page from your watchlist',
228 'oldimage' =>
'The name of the old image to delete as provided by iiprop=archivename'
236 'reason' =>
'string',
243 return 'Delete a page.';
247 return array_merge( parent::getPossibleErrors(),
250 array(
'notanarticle' ),
251 array(
'hookaborted',
'error' ),
252 array(
'delete-toobig',
'limit' ),
253 array(
'cannotdelete',
'title' ),
254 array(
'invalidoldimage' ),
255 array(
'nodeleteablefile' ),
270 'api.php?action=delete&title=Main%20Page&token=123ABC' =>
'Delete the Main Page',
271 'api.php?action=delete&title=Main%20Page&token=123ABC&reason=Preparing%20for%20move'
272 =>
'Delete the Main Page with the reason "Preparing for move"',
277 return 'https://www.mediawiki.org/wiki/API:Delete';
dieStatus( $status)
Throw a UsageException based on the errors in the Status object.
Abstract class for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)
static singleton()
Get a RepoGroup instance.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
getParamDescription()
Returns an array of parameter descriptions.
dieUsageMsg( $error)
Output the error message related to a certain array.
getTokenSalt()
Returns the token salt if there is one, '' if the module doesn't require a salt, else false if the mo...
getTitleOrPageId( $params, $load=false)
getResult()
Get the result object.
getDescription()
Returns the description string for this module.
getUser()
Get the User object.
This abstract class implements many basic API functions, and is the base of all API classes.
getExamples()
Returns usage examples for this module.
needsToken()
Returns whether this module requires a token to execute It is used to show possible errors in action=...
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getResultProperties()
Returns possible properties in the result, grouped by the value of the prop parameter that shows them...
API module that facilitates deleting pages.
mustBePosted()
Indicates whether this module must be called with a POST request.
execute()
Extracts the title, token, and reason from the request parameters and invokes the local delete() func...
static delete(Page $page, User $user, $token, &$reason=null)
We have our own delete() function, since Article.php's implementation is split in two phases.
getPossibleErrors()
Returns a list of all possible errors returned by the module.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
setWatch( $watch, $titleObj, $userOption=null)
Set a watch (or unwatch) based the based on a watchlist parameter.
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
presenting them properly to the user as errors is done by the caller $title
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
if(PHP_SAPI !='cli') $file
static deleteFile(Page $page, User $user, $token, $oldimage, &$reason=null, $suppress=false)
getModuleName()
Get the name of the module being executed by this instance.
isWriteMode()
Indicates whether this module requires write mode.
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead where the first element is the message key and the remaining elements are used as parameters to the message based on mime etc Preferred in most cases over UploadVerification object with all info about the upload string as detected by MediaWiki Handlers will typically only apply for specific mime types object & $error
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static getPermissionsError( $title, $user, $token)
getTitleOrPageIdErrorMessage()