2007-12-06 16:06:22 +00:00
|
|
|
<?php
|
2010-02-19 12:54:09 +00:00
|
|
|
/**
|
2023-03-16 17:27:37 +00:00
|
|
|
* Copyright © 2007 Roan Kattouw <roan.kattouw@gmail.com>
|
2007-12-06 16:06:22 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
2010-06-21 13:13:32 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2007-12-06 16:06:22 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2010-08-07 19:59:42 +00:00
|
|
|
*
|
|
|
|
|
* @file
|
2007-12-06 16:06:22 +00:00
|
|
|
*/
|
|
|
|
|
|
2024-09-25 16:17:29 +00:00
|
|
|
namespace MediaWiki\Api;
|
|
|
|
|
|
|
|
|
|
use ChangeTags;
|
|
|
|
|
use File;
|
2022-04-13 15:28:26 +00:00
|
|
|
use MediaWiki\MainConfigNames;
|
2021-11-25 16:02:49 +00:00
|
|
|
use MediaWiki\Page\DeletePage;
|
2021-09-16 23:44:22 +00:00
|
|
|
use MediaWiki\Page\DeletePageFactory;
|
2023-03-09 20:01:39 +00:00
|
|
|
use MediaWiki\Page\File\FileDeleteForm;
|
2023-08-25 12:29:41 +00:00
|
|
|
use MediaWiki\Status\Status;
|
2019-11-30 11:55:36 +00:00
|
|
|
use MediaWiki\Title\Title;
|
2023-11-29 10:21:43 +00:00
|
|
|
use MediaWiki\User\Options\UserOptionsLookup;
|
2021-07-04 12:47:21 +00:00
|
|
|
use MediaWiki\Watchlist\WatchlistManager;
|
2024-09-25 16:17:29 +00:00
|
|
|
use RepoGroup;
|
|
|
|
|
use StatusValue;
|
2022-06-05 23:18:50 +00:00
|
|
|
use Wikimedia\ParamValidator\ParamValidator;
|
2024-09-25 16:17:29 +00:00
|
|
|
use WikiPage;
|
2020-03-08 21:32:26 +00:00
|
|
|
|
2007-12-06 16:06:22 +00:00
|
|
|
/**
|
2010-10-20 18:50:33 +00:00
|
|
|
* API module that facilitates deleting pages. The API equivalent of action=delete.
|
2008-01-12 07:08:17 +00:00
|
|
|
* Requires API write mode to be enabled.
|
|
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup API
|
2007-12-06 16:06:22 +00:00
|
|
|
*/
|
|
|
|
|
class ApiDelete extends ApiBase {
|
2020-06-04 20:16:23 +00:00
|
|
|
|
|
|
|
|
use ApiWatchlistTrait;
|
|
|
|
|
|
2023-08-28 15:32:58 +00:00
|
|
|
private RepoGroup $repoGroup;
|
|
|
|
|
private DeletePageFactory $deletePageFactory;
|
2021-09-16 23:44:22 +00:00
|
|
|
|
2021-06-29 20:48:17 +00:00
|
|
|
public function __construct(
|
|
|
|
|
ApiMain $mainModule,
|
2024-10-14 20:12:27 +00:00
|
|
|
string $moduleName,
|
2021-07-04 12:47:21 +00:00
|
|
|
RepoGroup $repoGroup,
|
|
|
|
|
WatchlistManager $watchlistManager,
|
2021-09-16 23:44:22 +00:00
|
|
|
UserOptionsLookup $userOptionsLookup,
|
|
|
|
|
DeletePageFactory $deletePageFactory
|
2021-06-29 20:48:17 +00:00
|
|
|
) {
|
|
|
|
|
parent::__construct( $mainModule, $moduleName );
|
|
|
|
|
$this->repoGroup = $repoGroup;
|
2021-09-16 23:44:22 +00:00
|
|
|
$this->deletePageFactory = $deletePageFactory;
|
2020-06-04 20:16:23 +00:00
|
|
|
|
2021-07-04 12:47:21 +00:00
|
|
|
// Variables needed in ApiWatchlistTrait trait
|
2022-04-13 15:28:26 +00:00
|
|
|
$this->watchlistExpiryEnabled = $this->getConfig()->get( MainConfigNames::WatchlistExpiry );
|
|
|
|
|
$this->watchlistMaxDuration =
|
|
|
|
|
$this->getConfig()->get( MainConfigNames::WatchlistExpiryMaxDuration );
|
2021-07-04 12:47:21 +00:00
|
|
|
$this->watchlistManager = $watchlistManager;
|
|
|
|
|
$this->userOptionsLookup = $userOptionsLookup;
|
2020-06-04 20:16:23 +00:00
|
|
|
}
|
|
|
|
|
|
2007-12-06 16:06:22 +00:00
|
|
|
/**
|
2015-10-08 07:34:27 +00:00
|
|
|
* Extracts the title and reason from the request parameters and invokes
|
2008-04-14 07:45:50 +00:00
|
|
|
* the local delete() function with these as arguments. It does not make use of
|
|
|
|
|
* the delete function specified by Article.php. If the deletion succeeds, the
|
|
|
|
|
* details of the article deleted and the reason for deletion are added to the
|
2008-01-12 07:08:17 +00:00
|
|
|
* result object.
|
2007-12-06 16:06:22 +00:00
|
|
|
*/
|
|
|
|
|
public function execute() {
|
2015-08-08 00:08:33 +00:00
|
|
|
$this->useTransactionalTimeLimit();
|
|
|
|
|
|
2007-12-06 16:06:22 +00:00
|
|
|
$params = $this->extractRequestParams();
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2012-04-28 13:45:37 +00:00
|
|
|
$pageObj = $this->getTitleOrPageId( $params, 'fromdbmaster' );
|
2017-06-12 17:09:26 +00:00
|
|
|
$titleObj = $pageObj->getTitle();
|
2021-05-21 15:44:24 +00:00
|
|
|
$this->getErrorFormatter()->setContextTitle( $titleObj );
|
2017-06-12 17:09:26 +00:00
|
|
|
if ( !$pageObj->exists() &&
|
2019-08-31 16:14:38 +00:00
|
|
|
// @phan-suppress-next-line PhanUndeclaredMethod
|
2020-07-22 17:29:48 +00:00
|
|
|
!( $titleObj->getNamespace() === NS_FILE && self::canDeleteFile( $pageObj->getFile() ) )
|
2017-06-12 17:09:26 +00:00
|
|
|
) {
|
2016-10-19 16:54:25 +00:00
|
|
|
$this->dieWithError( 'apierror-missingtitle' );
|
2010-02-19 12:54:09 +00:00
|
|
|
}
|
2007-12-06 16:06:22 +00:00
|
|
|
|
2012-07-07 07:12:04 +00:00
|
|
|
$reason = $params['reason'];
|
2011-11-16 15:57:56 +00:00
|
|
|
$user = $this->getUser();
|
|
|
|
|
|
2021-09-16 23:44:22 +00:00
|
|
|
$tags = $params['tags'] ?: [];
|
2015-10-08 07:34:27 +00:00
|
|
|
|
2020-07-22 17:29:48 +00:00
|
|
|
if ( $titleObj->getNamespace() === NS_FILE ) {
|
2021-06-29 20:48:17 +00:00
|
|
|
$status = $this->deleteFile(
|
2013-11-16 19:09:17 +00:00
|
|
|
$pageObj,
|
|
|
|
|
$params['oldimage'],
|
|
|
|
|
$reason,
|
2016-09-21 17:18:08 +00:00
|
|
|
false,
|
2022-02-22 05:18:40 +00:00
|
|
|
$tags,
|
|
|
|
|
$params['deletetalk']
|
2013-11-16 19:09:17 +00:00
|
|
|
);
|
Use DeletePage in FileDeleteForm and fix output of ApiDelete
- Use DeletePage in FileDeleteForm instead of
WikiPage::doDeleteArticleReal
- Properly handle scheduled deletions in FileDeleteForm: previously, a
null status value could indicate a missing page OR a scheduled
deletion, but the code always assumed the first, and it would generate
a duplicated log entry. The API response would also not contain the
"delete-scheduled" message. This has been broken since the introduction
of scheduled deletion.
- In ApiDelete, for file deletions, check whether the status is OK not
good. The two might be equivalent, but this way it's more consistent.
- Add some documentation for the Status objects returned by file-related
methods. This is still incomplete, as there are many methods using
Status and none of them says what the status could be. In particular,
this means that for now we keep checking whether the status is OK
instead of good, even though it's unclear what could produce a
non-fatal error.
- In LocalFileDeleteBatch, avoid using a class property for the returned
status, as that's hard to follow. Instead, use a local variable and
pass it around when needed.
Bug: T288758
Change-Id: I22d60c05bdd4a3ea531e63dbb9e49efc36935137
2021-10-12 12:42:16 +00:00
|
|
|
// TODO What kind of non-fatal errors should we expect here?
|
|
|
|
|
$wasScheduled = $status->isOK() && $status->getValue() === false;
|
2008-05-19 21:30:03 +00:00
|
|
|
} else {
|
2022-02-22 05:18:40 +00:00
|
|
|
$status = $this->delete( $pageObj, $reason, $tags, $params['deletetalk'] );
|
Use DeletePage in FileDeleteForm and fix output of ApiDelete
- Use DeletePage in FileDeleteForm instead of
WikiPage::doDeleteArticleReal
- Properly handle scheduled deletions in FileDeleteForm: previously, a
null status value could indicate a missing page OR a scheduled
deletion, but the code always assumed the first, and it would generate
a duplicated log entry. The API response would also not contain the
"delete-scheduled" message. This has been broken since the introduction
of scheduled deletion.
- In ApiDelete, for file deletions, check whether the status is OK not
good. The two might be equivalent, but this way it's more consistent.
- Add some documentation for the Status objects returned by file-related
methods. This is still incomplete, as there are many methods using
Status and none of them says what the status could be. In particular,
this means that for now we keep checking whether the status is OK
instead of good, even though it's unclear what could produce a
non-fatal error.
- In LocalFileDeleteBatch, avoid using a class property for the returned
status, as that's hard to follow. Instead, use a local variable and
pass it around when needed.
Bug: T288758
Change-Id: I22d60c05bdd4a3ea531e63dbb9e49efc36935137
2021-10-12 12:42:16 +00:00
|
|
|
$wasScheduled = $status->isGood() && $status->getValue() === false;
|
2011-11-16 15:57:56 +00:00
|
|
|
}
|
2010-02-19 12:54:09 +00:00
|
|
|
|
2019-03-29 23:20:50 +00:00
|
|
|
if ( !$status->isOK() ) {
|
2013-06-13 17:56:29 +00:00
|
|
|
$this->dieStatus( $status );
|
2011-11-16 15:57:56 +00:00
|
|
|
}
|
Use DeletePage in FileDeleteForm and fix output of ApiDelete
- Use DeletePage in FileDeleteForm instead of
WikiPage::doDeleteArticleReal
- Properly handle scheduled deletions in FileDeleteForm: previously, a
null status value could indicate a missing page OR a scheduled
deletion, but the code always assumed the first, and it would generate
a duplicated log entry. The API response would also not contain the
"delete-scheduled" message. This has been broken since the introduction
of scheduled deletion.
- In ApiDelete, for file deletions, check whether the status is OK not
good. The two might be equivalent, but this way it's more consistent.
- Add some documentation for the Status objects returned by file-related
methods. This is still incomplete, as there are many methods using
Status and none of them says what the status could be. In particular,
this means that for now we keep checking whether the status is OK
instead of good, even though it's unclear what could produce a
non-fatal error.
- In LocalFileDeleteBatch, avoid using a class property for the returned
status, as that's hard to follow. Instead, use a local variable and
pass it around when needed.
Bug: T288758
Change-Id: I22d60c05bdd4a3ea531e63dbb9e49efc36935137
2021-10-12 12:42:16 +00:00
|
|
|
|
2021-09-16 23:44:22 +00:00
|
|
|
if ( $wasScheduled ) {
|
2021-10-20 21:56:10 +00:00
|
|
|
$this->addWarning( [ 'delete-scheduled', $titleObj->getPrefixedText() ] );
|
2021-09-16 23:44:22 +00:00
|
|
|
}
|
2010-02-19 01:25:57 +00:00
|
|
|
|
2011-11-16 15:57:56 +00:00
|
|
|
// Deprecated parameters
|
|
|
|
|
if ( $params['watch'] ) {
|
|
|
|
|
$watch = 'watch';
|
|
|
|
|
} elseif ( $params['unwatch'] ) {
|
|
|
|
|
$watch = 'unwatch';
|
|
|
|
|
} else {
|
|
|
|
|
$watch = $params['watchlist'];
|
2008-05-19 21:30:03 +00:00
|
|
|
}
|
2020-06-04 20:16:23 +00:00
|
|
|
|
|
|
|
|
$watchlistExpiry = $this->getExpiryFromParams( $params );
|
2020-09-04 12:31:40 +00:00
|
|
|
$this->setWatch( $watch, $titleObj, $user, 'watchdeletion', $watchlistExpiry );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$r = [
|
2012-05-14 01:20:05 +00:00
|
|
|
'title' => $titleObj->getPrefixedText(),
|
|
|
|
|
'reason' => $reason,
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2020-06-04 20:16:23 +00:00
|
|
|
|
2022-02-22 05:18:40 +00:00
|
|
|
// TODO: We could expose additional information (scheduled and log ID) about the status of the talk page
|
|
|
|
|
// deletion.
|
2021-09-16 23:44:22 +00:00
|
|
|
if ( $wasScheduled ) {
|
2018-12-20 14:59:02 +00:00
|
|
|
$r['scheduled'] = true;
|
2021-09-16 23:44:22 +00:00
|
|
|
} else {
|
2018-12-20 14:59:02 +00:00
|
|
|
// Scheduled deletions don't currently have a log entry available at this point
|
2021-11-25 16:02:49 +00:00
|
|
|
$r['logid'] = $status->value;
|
2018-12-20 14:59:02 +00:00
|
|
|
}
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->getResult()->addValue( null, $this->getModuleName(), $r );
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
2008-01-12 07:08:17 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* We have our own delete() function, since Article.php's implementation is split in two phases
|
|
|
|
|
*
|
2020-03-17 16:56:06 +00:00
|
|
|
* @param WikiPage $page WikiPage object to work on
|
2017-08-11 00:23:16 +00:00
|
|
|
* @param string|null &$reason Reason for the deletion. Autogenerated if null
|
2020-11-20 13:12:54 +00:00
|
|
|
* @param string[] $tags Tags to tag the deletion with
|
2022-02-22 05:18:40 +00:00
|
|
|
* @param bool $deleteTalk
|
2021-10-18 13:19:15 +00:00
|
|
|
* @return StatusValue Same as DeletePage::deleteIfAllowed, but if the status is good, then:
|
2021-11-25 16:02:49 +00:00
|
|
|
* - For immediate deletions, the value is the ID of the deletion
|
2021-10-18 13:19:15 +00:00
|
|
|
* - For scheduled deletions, the value is false
|
2022-02-22 05:18:40 +00:00
|
|
|
* If $deleteTalk is set, no information about the deletion of the talk page is included in the returned Status.
|
2008-01-12 07:08:17 +00:00
|
|
|
*/
|
2022-02-22 05:18:40 +00:00
|
|
|
private function delete( WikiPage $page, &$reason, array $tags, bool $deleteTalk ): StatusValue {
|
2011-11-16 15:57:56 +00:00
|
|
|
$title = $page->getTitle();
|
2008-01-12 07:08:17 +00:00
|
|
|
|
|
|
|
|
// Auto-generate a summary, if necessary
|
2020-01-09 23:48:34 +00:00
|
|
|
if ( $reason === null ) {
|
2021-08-16 21:14:18 +00:00
|
|
|
$reason = $page->getAutoDeleteReason();
|
2010-02-19 12:54:09 +00:00
|
|
|
if ( $reason === false ) {
|
2018-03-18 19:58:02 +00:00
|
|
|
// Should be reachable only if the page has no revisions
|
|
|
|
|
return Status::newFatal( 'cannotdelete', $title->getPrefixedText() ); // @codeCoverageIgnore
|
2010-02-19 12:54:09 +00:00
|
|
|
}
|
2008-01-12 07:08:17 +00:00
|
|
|
}
|
2009-01-29 01:04:00 +00:00
|
|
|
|
2021-09-16 23:44:22 +00:00
|
|
|
$deletePage = $this->deletePageFactory->newDeletePage( $page, $this->getAuthority() );
|
2022-02-22 05:18:40 +00:00
|
|
|
if ( $deleteTalk ) {
|
|
|
|
|
$checkStatus = $deletePage->canProbablyDeleteAssociatedTalk();
|
|
|
|
|
if ( !$checkStatus->isGood() ) {
|
2024-04-08 19:01:35 +00:00
|
|
|
foreach ( $checkStatus->getMessages() as $msg ) {
|
|
|
|
|
$this->addWarning( $msg );
|
2022-02-22 05:18:40 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$deletePage->setDeleteAssociatedTalk( true );
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-10-18 13:19:15 +00:00
|
|
|
$deletionStatus = $deletePage->setTags( $tags )->deleteIfAllowed( $reason );
|
2022-02-22 05:18:40 +00:00
|
|
|
if ( $deletionStatus->isGood() ) {
|
|
|
|
|
$deletionStatus->value = $deletePage->deletionsWereScheduled()[DeletePage::PAGE_BASE]
|
|
|
|
|
? false
|
|
|
|
|
: $deletePage->getSuccessfulDeletionsIDs()[DeletePage::PAGE_BASE];
|
|
|
|
|
}
|
2021-10-18 13:19:15 +00:00
|
|
|
return $deletionStatus;
|
2008-01-12 07:08:17 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2017-06-12 17:09:26 +00:00
|
|
|
/**
|
|
|
|
|
* @param File $file
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
protected static function canDeleteFile( File $file ) {
|
|
|
|
|
return $file->exists() && $file->isLocal() && !$file->getRedirected();
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-09 00:01:45 +00:00
|
|
|
/**
|
2020-03-17 16:56:06 +00:00
|
|
|
* @param WikiPage $page Object to work on
|
2013-11-17 19:04:13 +00:00
|
|
|
* @param string $oldimage Archive name
|
2018-06-26 21:14:43 +00:00
|
|
|
* @param string|null &$reason Reason for the deletion. Autogenerated if null.
|
2013-11-17 19:04:13 +00:00
|
|
|
* @param bool $suppress Whether to mark all deleted versions as restricted
|
2020-11-20 13:12:54 +00:00
|
|
|
* @param string[] $tags Tags to tag the deletion with
|
2022-02-22 05:18:40 +00:00
|
|
|
* @param bool $deleteTalk
|
2021-09-16 23:44:22 +00:00
|
|
|
* @return StatusValue
|
2010-10-09 00:01:45 +00:00
|
|
|
*/
|
2022-02-22 05:18:40 +00:00
|
|
|
private function deleteFile(
|
|
|
|
|
WikiPage $page,
|
|
|
|
|
$oldimage,
|
|
|
|
|
&$reason,
|
|
|
|
|
bool $suppress,
|
|
|
|
|
array $tags,
|
|
|
|
|
bool $deleteTalk
|
2013-11-16 19:09:17 +00:00
|
|
|
) {
|
2011-11-16 15:57:56 +00:00
|
|
|
$title = $page->getTitle();
|
2008-05-19 21:30:03 +00:00
|
|
|
|
2019-08-31 16:14:38 +00:00
|
|
|
// @phan-suppress-next-line PhanUndeclaredMethod There's no right typehint for it
|
2011-11-16 15:57:56 +00:00
|
|
|
$file = $page->getFile();
|
2017-06-12 17:09:26 +00:00
|
|
|
if ( !self::canDeleteFile( $file ) ) {
|
2022-02-22 05:18:40 +00:00
|
|
|
return $this->delete( $page, $reason, $tags, $deleteTalk );
|
2021-09-16 23:44:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check that the user is allowed to carry out the deletion
|
|
|
|
|
$this->checkTitleUserPermissions( $page->getTitle(), 'delete' );
|
|
|
|
|
if ( $tags ) {
|
|
|
|
|
// If change tagging was requested, check that the user is allowed to tag,
|
|
|
|
|
// and the tags are valid
|
|
|
|
|
$tagStatus = ChangeTags::canAddTagsAccompanyingChange( $tags, $this->getAuthority() );
|
|
|
|
|
if ( !$tagStatus->isOK() ) {
|
|
|
|
|
$this->dieStatus( $tagStatus );
|
|
|
|
|
}
|
2010-02-19 12:54:09 +00:00
|
|
|
}
|
2008-05-19 21:30:03 +00:00
|
|
|
|
2010-02-19 12:54:09 +00:00
|
|
|
if ( $oldimage ) {
|
2011-11-16 15:57:56 +00:00
|
|
|
if ( !FileDeleteForm::isValidOldSpec( $oldimage ) ) {
|
2016-10-19 16:54:25 +00:00
|
|
|
return Status::newFatal( 'invalidoldimage' );
|
2011-11-16 15:57:56 +00:00
|
|
|
}
|
2021-06-29 20:48:17 +00:00
|
|
|
$oldfile = $this->repoGroup->getLocalRepo()->newFromArchiveName( $title, $oldimage );
|
2011-11-16 15:57:56 +00:00
|
|
|
if ( !$oldfile->exists() || !$oldfile->isLocal() || $oldfile->getRedirected() ) {
|
2016-10-19 16:54:25 +00:00
|
|
|
return Status::newFatal( 'nodeleteablefile' );
|
2011-11-16 15:57:56 +00:00
|
|
|
}
|
2010-02-19 12:54:09 +00:00
|
|
|
}
|
|
|
|
|
|
2022-02-22 05:18:40 +00:00
|
|
|
return FileDeleteForm::doDelete(
|
|
|
|
|
$title,
|
|
|
|
|
$file,
|
|
|
|
|
$oldimage,
|
2024-08-15 09:48:40 +00:00
|
|
|
// Log and RC don't like null reasons
|
|
|
|
|
$reason ?? '',
|
2022-02-22 05:18:40 +00:00
|
|
|
$suppress,
|
|
|
|
|
$this->getUser(),
|
|
|
|
|
$tags,
|
|
|
|
|
$deleteTalk
|
|
|
|
|
);
|
2008-05-19 21:30:03 +00:00
|
|
|
}
|
2010-02-19 12:54:09 +00:00
|
|
|
|
2010-02-14 21:12:11 +00:00
|
|
|
public function mustBePosted() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2009-03-06 13:49:44 +00:00
|
|
|
public function isWriteMode() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getAllowedParams() {
|
2020-06-04 20:16:23 +00:00
|
|
|
$params = [
|
2007-12-06 16:06:22 +00:00
|
|
|
'title' => null,
|
2016-02-17 09:09:32 +00:00
|
|
|
'pageid' => [
|
2022-06-05 23:18:50 +00:00
|
|
|
ParamValidator::PARAM_TYPE => 'integer'
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2007-12-06 16:06:22 +00:00
|
|
|
'reason' => null,
|
2016-02-17 09:09:32 +00:00
|
|
|
'tags' => [
|
2022-06-05 23:18:50 +00:00
|
|
|
ParamValidator::PARAM_TYPE => 'tags',
|
|
|
|
|
ParamValidator::PARAM_ISMULTI => true,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2022-02-22 05:18:40 +00:00
|
|
|
'deletetalk' => false,
|
2016-02-17 09:09:32 +00:00
|
|
|
'watch' => [
|
2022-06-05 23:18:50 +00:00
|
|
|
ParamValidator::PARAM_DEFAULT => false,
|
2022-06-06 01:24:41 +00:00
|
|
|
ParamValidator::PARAM_DEPRECATED => true,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2020-06-04 20:16:23 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// Params appear in the docs in the order they are defined,
|
|
|
|
|
// which is why this is here and not at the bottom.
|
|
|
|
|
$params += $this->getWatchlistParams();
|
|
|
|
|
|
|
|
|
|
return $params + [
|
2016-02-17 09:09:32 +00:00
|
|
|
'unwatch' => [
|
2022-06-05 23:18:50 +00:00
|
|
|
ParamValidator::PARAM_DEFAULT => false,
|
2022-06-06 01:24:41 +00:00
|
|
|
ParamValidator::PARAM_DEPRECATED => true,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2010-10-13 23:11:40 +00:00
|
|
|
'oldimage' => null,
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
|
|
|
|
|
2010-10-01 20:12:50 +00:00
|
|
|
public function needsToken() {
|
2014-08-08 16:56:07 +00:00
|
|
|
return 'csrf';
|
2010-02-14 22:20:27 +00:00
|
|
|
}
|
2007-12-06 16:06:22 +00:00
|
|
|
|
2014-10-28 17:17:02 +00:00
|
|
|
protected function getExamplesMessages() {
|
2019-11-30 11:55:36 +00:00
|
|
|
$title = Title::newMainPage()->getPrefixedText();
|
|
|
|
|
$mp = rawurlencode( $title );
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2019-11-30 11:55:36 +00:00
|
|
|
"action=delete&title={$mp}&token=123ABC"
|
2014-09-18 17:38:23 +00:00
|
|
|
=> 'apihelp-delete-example-simple',
|
2019-11-30 11:55:36 +00:00
|
|
|
"action=delete&title={$mp}&token=123ABC&reason=Preparing%20for%20move"
|
2014-09-18 17:38:23 +00:00
|
|
|
=> 'apihelp-delete-example-reason',
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
|
|
|
|
|
2011-07-17 16:38:24 +00:00
|
|
|
public function getHelpUrls() {
|
2017-04-04 22:52:57 +00:00
|
|
|
return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Delete';
|
2011-07-17 16:38:24 +00:00
|
|
|
}
|
2011-03-23 21:54:59 +00:00
|
|
|
}
|
2024-09-25 16:17:29 +00:00
|
|
|
|
|
|
|
|
/** @deprecated class alias since 1.43 */
|
|
|
|
|
class_alias( ApiDelete::class, 'ApiDelete' );
|