MediaWiki  master
Page\DeletePage Class Reference

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

Public Member Functions

 __construct (HookContainer $hookContainer, RevisionStore $revisionStore, LBFactory $lbFactory, JobQueueGroup $jobQueueGroup, CommentStore $commentStore, ServiceOptions $serviceOptions, BagOStuff $recentDeletesCache, string $localWikiID, string $webRequestID, WikiPageFactory $wikiPageFactory, UserFactory $userFactory, BacklinkCacheFactory $backlinkCacheFactory, NamespaceInfo $namespaceInfo, ITextFormatter $contLangMsgTextFormatter, ProperPageIdentity $page, Authority $deleter)
 
 canProbablyDeleteAssociatedTalk ()
 Tests whether it's probably possible to delete the associated talk page. More...
 
 deleteIfAllowed (string $reason)
 Same as deleteUnsafe, but checks permissions. More...
 
 deleteInternal (WikiPage $page, string $pageRole, string $reason, ?string $webRequestId=null)
 
 deleteUnsafe (string $reason)
 Back-end article deletion: deletes the article with database consistency, writes logs, purges caches. More...
 
 deletionsWereScheduled ()
 
 deletionWasScheduled ()
 
 doDeleteUpdates (WikiPage $page, RevisionRecord $revRecord)
 
 forceImmediate (bool $forceImmediate)
 If false, allows deleting over time via the job queue. More...
 
 getDeletionUpdates (WikiPage $page, RevisionRecord $rev)
 
 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). More...
 
 keepLegacyHookErrorsSeparate ()
 
 setDeleteAssociatedTalk (bool $delete)
 If set to true and the page has a talk page, delete that one too. More...
 
 setDeletionAttempted ()
 Called before attempting a deletion, allows the result getters to be used. More...
 
 setIsDeletePageUnitTest (bool $test)
 
 setLogSubtype (string $logSubtype)
 Set a specific log subtype for the deletion log entry. More...
 
 setSuppress (bool $suppress)
 If true, suppress all revisions and log the deletion in the suppression log instead of the deletion log. More...
 
 setTags (array $tags)
 Change tags to apply to the deletion action. More...
 

Public Attributes

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

Detailed Description

Backend logic for performing a page delete action.

Since
1.37

Definition at line 52 of file DeletePage.php.

Constructor & Destructor Documentation

◆ __construct()

Page\DeletePage::__construct ( HookContainer  $hookContainer,
RevisionStore  $revisionStore,
LBFactory  $lbFactory,
JobQueueGroup  $jobQueueGroup,
CommentStore  $commentStore,
ServiceOptions  $serviceOptions,
BagOStuff  $recentDeletesCache,
string  $localWikiID,
string  $webRequestID,
WikiPageFactory  $wikiPageFactory,
UserFactory  $userFactory,
BacklinkCacheFactory  $backlinkCacheFactory,
NamespaceInfo  $namespaceInfo,
ITextFormatter  $contLangMsgTextFormatter,
ProperPageIdentity  $page,
Authority  $deleter 
)
Access: internal
Create via the PageDeleteFactory service.
Parameters
HookContainer$hookContainer
RevisionStore$revisionStore
LBFactory$lbFactory
JobQueueGroup$jobQueueGroup
CommentStore$commentStore
ServiceOptions$serviceOptions
BagOStuff$recentDeletesCache
string$localWikiID
string$webRequestID
WikiPageFactory$wikiPageFactory
UserFactory$userFactory
BacklinkCacheFactory$backlinkCacheFactory
NamespaceInfo$namespaceInfo
ITextFormatter$contLangMsgTextFormatter
ProperPageIdentity$page
Authority$deleter

Definition at line 154 of file DeletePage.php.

References Page\WikiPageFactory\newFromTitle().

Member Function Documentation

◆ canProbablyDeleteAssociatedTalk()

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.

Returns
StatusValue

Definition at line 261 of file DeletePage.php.

References StatusValue\newFatal().

◆ deleteIfAllowed()

Page\DeletePage::deleteIfAllowed ( string  $reason)

Same as deleteUnsafe, but checks permissions.

Parameters
string$reason
Returns
StatusValue

Definition at line 376 of file DeletePage.php.

◆ deleteInternal()

Page\DeletePage::deleteInternal ( WikiPage  $page,
string  $pageRole,
string  $reason,
?string  $webRequestId = 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
Returns
Status

Definition at line 544 of file DeletePage.php.

◆ deleteUnsafe()

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 Status object:
  • If successful (or scheduled), a good Status
  • 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 464 of file DeletePage.php.

◆ deletionsWereScheduled()

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

Definition at line 365 of file DeletePage.php.

◆ deletionWasScheduled()

Page\DeletePage::deletionWasScheduled ( )
Returns
bool Whether (part of) the deletion was scheduled
Exceptions
BadMethodCallExceptionIf no deletions were attempted
Deprecated:
since 1.38, use ::deletionsWereScheduled() instead.

Definition at line 354 of file DeletePage.php.

◆ doDeleteUpdates()

Page\DeletePage::doDeleteUpdates ( WikiPage  $page,
RevisionRecord  $revRecord 
)
Access: private
Public for BC only Do some database updates after deletion
Parameters
WikiPage$page
RevisionRecord$revRecordThe current page revision at the time of deletion, used when determining the required updates. This may be needed because $page->getRevisionRecord() may already return null when the page proper was deleted.

Definition at line 841 of file DeletePage.php.

◆ forceImmediate()

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 250 of file DeletePage.php.

◆ getDeletionUpdates()

Page\DeletePage::getDeletionUpdates ( WikiPage  $page,
RevisionRecord  $rev 
)
Access: private
Public for BC only Returns a list of updates to be performed when the page is deleted. The updates should remove any information about this page from secondary data stores such as links tables.
Parameters
WikiPage$page
RevisionRecord$revThe revision being deleted.
Returns
DeferrableUpdate[]

Definition at line 918 of file DeletePage.php.

◆ getLegacyHookErrors()

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

Definition at line 197 of file DeletePage.php.

◆ getSuccessfulDeletionsIDs()

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

Definition at line 344 of file DeletePage.php.

◆ isBatchedDelete()

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 437 of file DeletePage.php.

◆ keepLegacyHookErrorsSeparate()

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

Definition at line 205 of file DeletePage.php.

◆ setDeleteAssociatedTalk()

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 286 of file DeletePage.php.

◆ setDeletionAttempted()

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 319 of file DeletePage.php.

◆ setIsDeletePageUnitTest()

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 307 of file DeletePage.php.

◆ setLogSubtype()

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 239 of file DeletePage.php.

◆ setSuppress()

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 217 of file DeletePage.php.

◆ setTags()

Page\DeletePage::setTags ( array  $tags)

Change tags to apply to the deletion action.

Parameters
string[]$tags
Returns
self For chaining

Definition at line 228 of file DeletePage.php.

Member Data Documentation

◆ CONSTRUCTOR_OPTIONS

const 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 56 of file DeletePage.php.

◆ PAGE_BASE

const Page\DeletePage::PAGE_BASE = 'base'

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

Definition at line 64 of file DeletePage.php.

◆ PAGE_TALK

const Page\DeletePage::PAGE_TALK = 'talk'

Definition at line 65 of file DeletePage.php.


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