MediaWiki master
MediaWiki\Page\DeletePage Class Reference

Backend logic for performing a page delete action. More...

Public Member Functions

 __construct (HookContainer $hookContainer, private readonly DomainEventDispatcher $eventDispatcher, private readonly RevisionStore $revisionStore, private readonly LBFactory $lbFactory, private readonly JobQueueGroup $jobQueueGroup, private readonly CommentStore $commentStore, private readonly ServiceOptions $options, private readonly BagOStuff $recentDeletesCache, private readonly string $webRequestID, private readonly WikiPageFactory $wikiPageFactory, private readonly UserFactory $userFactory, private readonly BacklinkCacheFactory $backlinkCacheFactory, private readonly NamespaceInfo $namespaceInfo, private readonly ITextFormatter $contLangMsgTextFormatter, private readonly RedirectStore $redirectStore, ProperPageIdentity $page, private readonly Authority $deleter, private readonly WriteDuplicator $linkWriteDuplicator, private readonly UserEditTracker $userEditTracker)
 
 canProbablyDeleteAssociatedTalk ()
 Tests whether it's probably possible to delete the associated talk page.
 
 deleteIfAllowed (string $reason)
 Same as deleteUnsafe, but checks permissions.
 
 deleteInternal (WikiPage $page, string $pageRole, string $reason, ?string $webRequestId=null, $ticket=null)
 
 deleteUnsafe (string $reason)
 Back-end article deletion: deletes the article with database consistency, writes logs, purges caches.
 
 deletionsWereScheduled ()
 
 forceImmediate (bool $forceImmediate)
 If false, allows deleting over time via the job queue.
 
 getLegacyHookErrors ()
 
 getSuccessfulDeletionsIDs ()
 
 isBatchedDelete (int $safetyMargin=0)
 Determines if this deletion would be batched (executed over time by the job queue) or not (completed in the same request as the delete call).
 
 keepLegacyHookErrorsSeparate ()
 
 setDeleteAssociatedTalk (bool $delete)
 If set to true and the page has a talk page, delete that one too.
 
 setDeletionAttempted ()
 Called before attempting a deletion, allows the result getters to be used.
 
 setIsDeletePageUnitTest (bool $test)
 
 setLogSubtype (string $logSubtype)
 Set a specific log subtype for the deletion log entry.
 
 setSuppress (bool $suppress)
 If true, suppress all revisions and log the deletion in the suppression log instead of the deletion log.
 
 setTags (array $tags)
 Change tags to apply to the deletion action.
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 
const PAGE_BASE = 'base'
 Constants used for the return value of getSuccessfulDeletionsIDs() and deletionsWereScheduled()
 
const PAGE_TALK = 'talk'
 

Detailed Description

Backend logic for performing a page delete action.

Since
1.37

Definition at line 56 of file DeletePage.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Page\DeletePage::__construct ( HookContainer $hookContainer,
private readonly DomainEventDispatcher $eventDispatcher,
private readonly RevisionStore $revisionStore,
private readonly LBFactory $lbFactory,
private readonly JobQueueGroup $jobQueueGroup,
private readonly CommentStore $commentStore,
private readonly ServiceOptions $options,
private readonly BagOStuff $recentDeletesCache,
private readonly string $webRequestID,
private readonly WikiPageFactory $wikiPageFactory,
private readonly UserFactory $userFactory,
private readonly BacklinkCacheFactory $backlinkCacheFactory,
private readonly NamespaceInfo $namespaceInfo,
private readonly ITextFormatter $contLangMsgTextFormatter,
private readonly RedirectStore $redirectStore,
ProperPageIdentity $page,
private readonly Authority $deleter,
private readonly WriteDuplicator $linkWriteDuplicator,
private readonly UserEditTracker $userEditTracker )
Access: internal
Create via the PageDeleteFactory service.

Definition at line 108 of file DeletePage.php.

Member Function Documentation

◆ canProbablyDeleteAssociatedTalk()

MediaWiki\Page\DeletePage::canProbablyDeleteAssociatedTalk ( )

Tests whether it's probably possible to delete the associated talk page.

This checks the replica, so it may not see the latest master change, and is useful e.g. for building the UI.

Definition at line 200 of file DeletePage.php.

◆ deleteIfAllowed()

MediaWiki\Page\DeletePage::deleteIfAllowed ( string $reason)

Same as deleteUnsafe, but checks permissions.

Parameters
string$reason
Returns
StatusValue<never>

Definition at line 303 of file DeletePage.php.

◆ deleteInternal()

MediaWiki\Page\DeletePage::deleteInternal ( WikiPage $page,
string $pageRole,
string $reason,
?string $webRequestId = null,
$ticket = null )
Access: internal
The only external caller allowed is DeletePageJob. Back-end article deletion

Only invokes batching via the job queue if necessary per DeleteRevisionsBatchSize. Deletions can often be completed inline without involving the job queue.

Potentially called many times per deletion operation for pages with many revisions.

Parameters
WikiPage$page
string$pageRole
string$reason
string | null$webRequestId
mixed | null$ticketResult of ILBFactory::getEmptyTransactionTicket() or null
Returns
Status<never>

Definition at line 465 of file DeletePage.php.

◆ deleteUnsafe()

MediaWiki\Page\DeletePage::deleteUnsafe ( string $reason)

Back-end article deletion: deletes the article with database consistency, writes logs, purges caches.

Note
This method doesn't check user permissions. Use deleteIfAllowed for that.
Parameters
string$reasonDelete reason for deletion log
Returns
Status<never> Status object:
  • If successful (or scheduled), a good Status with no value
  • If a page couldn't be deleted because it wasn't found, a Status with a non-fatal 'cannotdelete' error.
  • A fatal Status otherwise.

Definition at line 385 of file DeletePage.php.

◆ deletionsWereScheduled()

MediaWiki\Page\DeletePage::deletionsWereScheduled ( )
Returns
bool[] Whether the deletions were scheduled
Exceptions
BadMethodCallExceptionIf no deletions were attempted

Definition at line 292 of file DeletePage.php.

◆ forceImmediate()

MediaWiki\Page\DeletePage::forceImmediate ( bool $forceImmediate)

If false, allows deleting over time via the job queue.

Parameters
bool$forceImmediate
Returns
self For chaining

Definition at line 191 of file DeletePage.php.

◆ getLegacyHookErrors()

MediaWiki\Page\DeletePage::getLegacyHookErrors ( )
Access: internal
BC method for use by WikiPage::doDeleteArticleReal only.
Returns
array|string

Definition at line 138 of file DeletePage.php.

◆ getSuccessfulDeletionsIDs()

MediaWiki\Page\DeletePage::getSuccessfulDeletionsIDs ( )
Returns
int[] Array of log IDs of successful deletions
Exceptions
BadMethodCallExceptionIf no deletions were attempted

Definition at line 283 of file DeletePage.php.

◆ isBatchedDelete()

MediaWiki\Page\DeletePage::isBatchedDelete ( int $safetyMargin = 0)

Determines if this deletion would be batched (executed over time by the job queue) or not (completed in the same request as the delete call).

It is unlikely but possible that an edit from another request could push the page over the batching threshold after this function is called, but before the caller acts upon the return value. Callers must decide for themselves how to deal with this. $safetyMargin is provided as an unreliable but situationally useful help for some common cases.

Parameters
int$safetyMarginAdded to the revision count when checking for batching
Returns
bool True if deletion would be batched, false otherwise

Definition at line 358 of file DeletePage.php.

◆ keepLegacyHookErrorsSeparate()

MediaWiki\Page\DeletePage::keepLegacyHookErrorsSeparate ( )
Access: internal
BC method for use by WikiPage::doDeleteArticleReal only.
Returns
self

Definition at line 146 of file DeletePage.php.

◆ setDeleteAssociatedTalk()

MediaWiki\Page\DeletePage::setDeleteAssociatedTalk ( bool $delete)

If set to true and the page has a talk page, delete that one too.

Callers should call canProbablyDeleteAssociatedTalk first to make sure this is a valid operation. Note that the checks here are laxer than those in canProbablyDeleteAssociatedTalk. In particular, this doesn't check whether the page exists as that may be subject to race condition, and it's checked later on (in deleteInternal, using latest data) anyway.

Parameters
bool$delete
Returns
self For chaining
Exceptions
BadMethodCallExceptionIf $delete is true and the given page is not a talk page.

Definition at line 225 of file DeletePage.php.

◆ setDeletionAttempted()

MediaWiki\Page\DeletePage::setDeletionAttempted ( )

Called before attempting a deletion, allows the result getters to be used.

Access: internal
The only external caller allowed is DeletePageJob.
Returns
self

Definition at line 258 of file DeletePage.php.

◆ setIsDeletePageUnitTest()

MediaWiki\Page\DeletePage::setIsDeletePageUnitTest ( bool $test)
Access: internal
FIXME: Hack used when running the DeletePage unit test to disable some legacy code.
Parameters
bool$test

Definition at line 246 of file DeletePage.php.

◆ setLogSubtype()

MediaWiki\Page\DeletePage::setLogSubtype ( string $logSubtype)

Set a specific log subtype for the deletion log entry.

Parameters
string$logSubtype
Returns
self For chaining

Definition at line 180 of file DeletePage.php.

◆ setSuppress()

MediaWiki\Page\DeletePage::setSuppress ( bool $suppress)

If true, suppress all revisions and log the deletion in the suppression log instead of the deletion log.

Parameters
bool$suppress
Returns
self For chaining

Definition at line 158 of file DeletePage.php.

◆ setTags()

MediaWiki\Page\DeletePage::setTags ( array $tags)

Change tags to apply to the deletion action.

Parameters
string[]$tags
Returns
self For chaining

Definition at line 169 of file DeletePage.php.

Member Data Documentation

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\Page\DeletePage::CONSTRUCTOR_OPTIONS
Initial value:
= [
]
const DeleteRevisionsLimit
Name constant for the DeleteRevisionsLimit setting, for use with Config::get()
const DeleteRevisionsBatchSize
Name constant for the DeleteRevisionsBatchSize setting, for use with Config::get()
Access: internal
For use by PageCommandFactory

Definition at line 60 of file DeletePage.php.

◆ PAGE_BASE

const MediaWiki\Page\DeletePage::PAGE_BASE = 'base'

Constants used for the return value of getSuccessfulDeletionsIDs() and deletionsWereScheduled()

Definition at line 68 of file DeletePage.php.

Referenced by MediaWiki\Page\DeletePageJob\run().

◆ PAGE_TALK

const MediaWiki\Page\DeletePage::PAGE_TALK = 'talk'

Definition at line 69 of file DeletePage.php.


The documentation for this class was generated from the following file: