MediaWiki  master
Page\DeletePage Class Reference
Collaboration diagram for Page\DeletePage:

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, ProperPageIdentity $page, Authority $deleter, BacklinkCacheFactory $backlinkCacheFactory)
 
 deleteIfAllowed (string $reason)
 Same as deleteUnsafe, but checks permissions. More...
 
 deleteInternal (string $reason, ?string $webRequestId=null)
 
 deleteUnsafe (string $reason)
 Back-end article deletion: deletes the article with database consistency, writes logs, purges caches. More...
 
 deletionWasScheduled ()
 
 doDeleteUpdates (RevisionRecord $revRecord)
 
 forceImmediate (bool $forceImmediate)
 If false, allows deleting over time via the job queue. More...
 
 getDeletionUpdates (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 ()
 
 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
 

Private Member Functions

 archiveRevisions (int $id)
 Archives revisions as part of page deletion. More...
 
 assertDeletionAttempted ()
 Asserts that a deletion operation was attempted. More...
 
 authorizeDeletion ()
 
 isBigDeletion ()
 
 setDeletionAttempted ()
 Called before attempting a deletion, allows the result getters to be used. More...
 

Private Attributes

bool $attemptedDeletion = false
 Whether a deletion was attempted. More...
 
BacklinkCacheFactory $backlinkCacheFactory
 
CommentStore $commentStore
 
Authority $deleter
 
bool $forceImmediate = false
 
HookRunner $hookRunner
 
bool $isDeletePageUnitTest = false
 
JobQueueGroup $jobQueueGroup
 
LBFactory $lbFactory
 
string array $legacyHookErrors = ''
 
ILoadBalancer $loadBalancer
 
string $localWikiID
 
string $logSubtype = 'delete'
 
bool $mergeLegacyHookErrors = true
 
ServiceOptions $options
 
WikiPage $page
 
BagOStuff $recentDeletesCache
 
RevisionStore $revisionStore
 
int[] null $successfulDeletionsIDs
 
bool $suppress = false
 
string[] $tags = []
 
UserFactory $userFactory
 
bool null $wasScheduled
 
string $webRequestID
 

Detailed Description

Definition at line 46 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,
ProperPageIdentity  $page,
Authority  $deleter,
BacklinkCacheFactory  $backlinkCacheFactory 
)
Parameters
HookContainer$hookContainer
RevisionStore$revisionStore
LBFactory$lbFactory
JobQueueGroup$jobQueueGroup
CommentStore$commentStore
ServiceOptions$serviceOptions
BagOStuff$recentDeletesCache
string$localWikiID
string$webRequestID
WikiPageFactory$wikiPageFactory
UserFactory$userFactory
ProperPageIdentity$page
Authority$deleter
BacklinkCacheFactory$backlinkCacheFactory

Definition at line 126 of file DeletePage.php.

References Page\DeletePage\$backlinkCacheFactory, Page\DeletePage\$commentStore, Page\DeletePage\$deleter, Page\DeletePage\$jobQueueGroup, Page\DeletePage\$lbFactory, Page\DeletePage\$localWikiID, Page\DeletePage\$page, Page\DeletePage\$recentDeletesCache, Page\DeletePage\$revisionStore, Page\DeletePage\$userFactory, Page\DeletePage\$webRequestID, and Page\WikiPageFactory\newFromTitle().

Member Function Documentation

◆ archiveRevisions()

Page\DeletePage::archiveRevisions ( int  $id)
private

Archives revisions as part of page deletion.

Parameters
int$id
Returns
bool

Definition at line 577 of file DeletePage.php.

References $res, $revQuery, DB_PRIMARY, SCHEMA_COMPAT_WRITE_TEMP, and MediaWiki\Revision\RevisionRecord\SUPPRESSED_ALL.

Referenced by Page\DeletePage\deleteInternal().

◆ assertDeletionAttempted()

Page\DeletePage::assertDeletionAttempted ( )
private

Asserts that a deletion operation was attempted.

Exceptions
BadMethodCallException

Definition at line 247 of file DeletePage.php.

Referenced by Page\DeletePage\deletionWasScheduled(), and Page\DeletePage\getSuccessfulDeletionsIDs().

◆ authorizeDeletion()

Page\DeletePage::authorizeDeletion ( )
private

◆ deleteIfAllowed()

Page\DeletePage::deleteIfAllowed ( string  $reason)

Same as deleteUnsafe, but checks permissions.

Parameters
string$reason
Returns
StatusValue

Definition at line 277 of file DeletePage.php.

References Page\DeletePage\authorizeDeletion(), Page\DeletePage\deleteUnsafe(), and Page\DeletePage\setDeletionAttempted().

◆ deleteInternal()

Page\DeletePage::deleteInternal ( 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
string$reason
string | null$webRequestId
Returns
Status

Definition at line 400 of file DeletePage.php.

References $content, $job, Page\DeletePage\$logSubtype, Page\DeletePage\$page, Page\DeletePage\$suppress, $title, Page\DeletePage\$webRequestID, Page\DeletePage\archiveRevisions(), DB_PRIMARY, Page\DeletePage\doDeleteUpdates(), Page\DeletePage\forceImmediate(), MediaWiki\Logger\LoggerFactory\getInstance(), StatusValue\newGood(), MediaWiki\Revision\RevisionRecord\RAW, Page\DeletePage\setDeletionAttempted(), wfEscapeWikiText(), and wfLogWarning().

Referenced by Page\DeletePage\deleteUnsafe().

◆ 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 the 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 354 of file DeletePage.php.

References Page\DeletePage\$legacyHookErrors, Page\DeletePage\deleteInternal(), StatusValue\newGood(), and Page\DeletePage\setDeletionAttempted().

Referenced by Page\DeletePage\deleteIfAllowed().

◆ deletionWasScheduled()

Page\DeletePage::deletionWasScheduled ( )
Returns
bool Whether (part of) the deletion was scheduled
Exceptions
BadMethodCallExceptionIf no deletions were attempted

Definition at line 266 of file DeletePage.php.

References Page\DeletePage\$wasScheduled, and Page\DeletePage\assertDeletionAttempted().

◆ doDeleteUpdates()

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

Definition at line 693 of file DeletePage.php.

References DeferredUpdates\addUpdate(), SiteStatsUpdate\factory(), Page\DeletePage\getDeletionUpdates(), ResourceLoaderWikiModule\invalidateModuleCache(), NS_FILE, WikiPage\onArticleDelete(), and LinksUpdate\queueRecursiveJobsForTable().

Referenced by Page\DeletePage\deleteInternal().

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

References Page\DeletePage\$forceImmediate.

Referenced by Page\DeletePage\deleteInternal().

◆ getDeletionUpdates()

Page\DeletePage::getDeletionUpdates ( 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
RevisionRecord$revThe revision being deleted.
Returns
DeferrableUpdate[]

Definition at line 767 of file DeletePage.php.

References $content.

Referenced by Page\DeletePage\doDeleteUpdates().

◆ getLegacyHookErrors()

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

Definition at line 164 of file DeletePage.php.

References Page\DeletePage\$legacyHookErrors.

◆ getSuccessfulDeletionsIDs()

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

Definition at line 257 of file DeletePage.php.

References Page\DeletePage\$successfulDeletionsIDs, and Page\DeletePage\assertDeletionAttempted().

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

References DB_REPLICA.

◆ isBigDeletion()

Page\DeletePage::isBigDeletion ( )
private
Returns
bool

Definition at line 308 of file DeletePage.php.

References DB_REPLICA.

◆ keepLegacyHookErrorsSeparate()

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

Definition at line 172 of file DeletePage.php.

◆ setDeletionAttempted()

Page\DeletePage::setDeletionAttempted ( )
private

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

Definition at line 237 of file DeletePage.php.

Referenced by Page\DeletePage\deleteIfAllowed(), Page\DeletePage\deleteInternal(), and Page\DeletePage\deleteUnsafe().

◆ 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 227 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 206 of file DeletePage.php.

References Page\DeletePage\$logSubtype.

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

References Page\DeletePage\$suppress.

◆ setTags()

Page\DeletePage::setTags ( array  $tags)

Change tags to apply to the deletion action.

Parameters
string[]$tags
Returns
self For chaining

Definition at line 195 of file DeletePage.php.

References Page\DeletePage\$tags.

Member Data Documentation

◆ $attemptedDeletion

bool Page\DeletePage::$attemptedDeletion = false
private

Whether a deletion was attempted.

Definition at line 108 of file DeletePage.php.

◆ $backlinkCacheFactory

BacklinkCacheFactory Page\DeletePage::$backlinkCacheFactory
private

Definition at line 79 of file DeletePage.php.

Referenced by Page\DeletePage\__construct().

◆ $commentStore

CommentStore Page\DeletePage::$commentStore
private

Definition at line 67 of file DeletePage.php.

Referenced by Page\DeletePage\__construct().

◆ $deleter

Authority Page\DeletePage::$deleter
private

Definition at line 87 of file DeletePage.php.

Referenced by Page\DeletePage\__construct().

◆ $forceImmediate

bool Page\DeletePage::$forceImmediate = false
private

Definition at line 96 of file DeletePage.php.

Referenced by Page\DeletePage\forceImmediate().

◆ $hookRunner

HookRunner Page\DeletePage::$hookRunner
private

Definition at line 57 of file DeletePage.php.

◆ $isDeletePageUnitTest

bool Page\DeletePage::$isDeletePageUnitTest = false
private

Definition at line 82 of file DeletePage.php.

◆ $jobQueueGroup

JobQueueGroup Page\DeletePage::$jobQueueGroup
private

Definition at line 65 of file DeletePage.php.

Referenced by Page\DeletePage\__construct().

◆ $lbFactory

LBFactory Page\DeletePage::$lbFactory
private

Definition at line 61 of file DeletePage.php.

Referenced by Page\DeletePage\__construct().

◆ $legacyHookErrors

string array Page\DeletePage::$legacyHookErrors = ''
private

◆ $loadBalancer

ILoadBalancer Page\DeletePage::$loadBalancer
private

Definition at line 63 of file DeletePage.php.

◆ $localWikiID

string Page\DeletePage::$localWikiID
private

Definition at line 73 of file DeletePage.php.

Referenced by Page\DeletePage\__construct().

◆ $logSubtype

string Page\DeletePage::$logSubtype = 'delete'
private

Definition at line 94 of file DeletePage.php.

Referenced by Page\DeletePage\deleteInternal(), and Page\DeletePage\setLogSubtype().

◆ $mergeLegacyHookErrors

bool Page\DeletePage::$mergeLegacyHookErrors = true
private

Definition at line 101 of file DeletePage.php.

◆ $options

ServiceOptions Page\DeletePage::$options
private

Definition at line 69 of file DeletePage.php.

◆ $page

WikiPage Page\DeletePage::$page
private

Definition at line 85 of file DeletePage.php.

Referenced by Page\DeletePage\__construct(), and Page\DeletePage\deleteInternal().

◆ $recentDeletesCache

BagOStuff Page\DeletePage::$recentDeletesCache
private

Definition at line 71 of file DeletePage.php.

Referenced by Page\DeletePage\__construct().

◆ $revisionStore

RevisionStore Page\DeletePage::$revisionStore
private

Definition at line 59 of file DeletePage.php.

Referenced by Page\DeletePage\__construct().

◆ $successfulDeletionsIDs

int [] null Page\DeletePage::$successfulDeletionsIDs
private

Definition at line 104 of file DeletePage.php.

Referenced by Page\DeletePage\getSuccessfulDeletionsIDs().

◆ $suppress

bool Page\DeletePage::$suppress = false
private

Definition at line 90 of file DeletePage.php.

Referenced by Page\DeletePage\deleteInternal(), and Page\DeletePage\setSuppress().

◆ $tags

string [] Page\DeletePage::$tags = []
private

Definition at line 92 of file DeletePage.php.

Referenced by Page\DeletePage\setTags().

◆ $userFactory

UserFactory Page\DeletePage::$userFactory
private

Definition at line 77 of file DeletePage.php.

Referenced by Page\DeletePage\__construct().

◆ $wasScheduled

bool null Page\DeletePage::$wasScheduled
private

Definition at line 106 of file DeletePage.php.

Referenced by Page\DeletePage\deletionWasScheduled().

◆ $webRequestID

string Page\DeletePage::$webRequestID
private

Definition at line 75 of file DeletePage.php.

Referenced by Page\DeletePage\__construct(), and Page\DeletePage\deleteInternal().

◆ CONSTRUCTOR_OPTIONS

const Page\DeletePage::CONSTRUCTOR_OPTIONS
Initial value:
= [
'DeleteRevisionsBatchSize',
'ActorTableSchemaMigrationStage',
'DeleteRevisionsLimit',
]
Access: internal
For use by PageCommandFactory

Definition at line 50 of file DeletePage.php.

Referenced by Page\PageCommandFactory\newDeletePage().


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