MediaWiki  master
CategoryMembershipChange Class Reference
Collaboration diagram for CategoryMembershipChange:

Public Member Functions

 __construct (Title $pageTitle, BacklinkCache $backlinkCache, RevisionRecord $revision=null)
 
 checkTemplateLinks ()
 Determines the number of template links for recursive link updates. More...
 
 overrideNewForCategorizationCallback (callable $callback)
 Overrides the default new for categorization callback This is intended for use while testing and will fail if MW_PHPUNIT_TEST is not defined. More...
 
 triggerCategoryAddedNotification (Title $categoryTitle)
 Create a recentchanges entry for category additions. More...
 
 triggerCategoryRemovedNotification (Title $categoryTitle)
 Create a recentchanges entry for category removals. More...
 

Private Member Functions

 createRecentChangesEntry (Title $categoryTitle, $type)
 Create a recentchanges entry using RecentChange::notifyCategorization() More...
 
 getChangeMessageText ( $type, $prefixedText, $numTemplateLinks)
 Returns the change message according to the type of category membership change. More...
 
 getPreviousRevisionTimestamp ()
 Returns the timestamp of the page's previous revision or null if the latest revision does not refer to a parent revision. More...
 
 getUser ()
 Get the user associated with this change. More...
 
 notifyCategorization ( $timestamp, Title $categoryTitle, ?UserIdentity $user, $comment, Title $pageTitle, $lastTimestamp, $revision, $added)
 

Private Attributes

BacklinkCache $backlinkCache
 
callable null $newForCategorizationCallback = null
 
int $numTemplateLinks = 0
 Number of pages this WikiPage is embedded by Set by CategoryMembershipChange::checkTemplateLinks() More...
 
Title $pageTitle
 Title instance of the categorized page. More...
 
RevisionRecord null $revision
 Latest revision of the categorized page. More...
 
string $timestamp
 Current timestamp, set during CategoryMembershipChange::__construct() More...
 
const CATEGORY_ADDITION = 1
 
const CATEGORY_REMOVAL = -1
 

Detailed Description

Definition at line 32 of file CategoryMembershipChange.php.

Constructor & Destructor Documentation

◆ __construct()

CategoryMembershipChange::__construct ( Title  $pageTitle,
BacklinkCache  $backlinkCache,
RevisionRecord  $revision = null 
)
Parameters
Title$pageTitleTitle instance of the categorized page
BacklinkCache$backlinkCache
RevisionRecord | null$revisionLatest revision of the categorized page.
Exceptions
MWException

Definition at line 74 of file CategoryMembershipChange.php.

References $backlinkCache, $pageTitle, $revision, MediaWiki\Revision\RevisionRecord\getTimestamp(), and wfTimestampNow().

Member Function Documentation

◆ checkTemplateLinks()

CategoryMembershipChange::checkTemplateLinks ( )

Determines the number of template links for recursive link updates.

Definition at line 107 of file CategoryMembershipChange.php.

◆ createRecentChangesEntry()

CategoryMembershipChange::createRecentChangesEntry ( Title  $categoryTitle,
  $type 
)
private

Create a recentchanges entry using RecentChange::notifyCategorization()

Parameters
Title$categoryTitle
int$type

Definition at line 135 of file CategoryMembershipChange.php.

References $type, getChangeMessageText(), getUser(), and notifyCategorization().

Referenced by triggerCategoryAddedNotification(), and triggerCategoryRemovedNotification().

◆ getChangeMessageText()

CategoryMembershipChange::getChangeMessageText (   $type,
  $prefixedText,
  $numTemplateLinks 
)
private

Returns the change message according to the type of category membership change.

The message keys created in this method may be one of:

  • recentchanges-page-added-to-category
  • recentchanges-page-added-to-category-bundled
  • recentchanges-page-removed-from-category
  • recentchanges-page-removed-from-category-bundled
Parameters
int$typemay be CategoryMembershipChange::CATEGORY_ADDITION or CategoryMembershipChange::CATEGORY_REMOVAL
string$prefixedTextresult of Title::->getPrefixedText()
int$numTemplateLinks
Returns
string

Definition at line 269 of file CategoryMembershipChange.php.

References $numTemplateLinks, $type, and wfMessage().

Referenced by createRecentChangesEntry().

◆ getPreviousRevisionTimestamp()

CategoryMembershipChange::getPreviousRevisionTimestamp ( )
private

Returns the timestamp of the page's previous revision or null if the latest revision does not refer to a parent revision.

Returns
null|string

Definition at line 290 of file CategoryMembershipChange.php.

◆ getUser()

CategoryMembershipChange::getUser ( )
private

Get the user associated with this change.

If there is no revision associated with the change and thus no editing user fallback to a default.

False will be returned if the user name specified in the 'autochange-username' message is invalid.

Returns
UserIdentity|null

Definition at line 233 of file CategoryMembershipChange.php.

References User\newFromName(), and wfMessage().

Referenced by createRecentChangesEntry().

◆ notifyCategorization()

CategoryMembershipChange::notifyCategorization (   $timestamp,
Title  $categoryTitle,
?UserIdentity  $user,
  $comment,
Title  $pageTitle,
  $lastTimestamp,
  $revision,
  $added 
)
private
Parameters
string$timestampTimestamp of the recent change to occur in TS_MW format
Title$categoryTitleTitle of the category a page is being added to or removed from
UserIdentity | null$userUser object of the user that made the change
string$commentChange summary
Title$pageTitleTitle of the page that is being added or removed
string$lastTimestampParent revision timestamp of this change in TS_MW format
RevisionRecord | null$revision
bool$addedtrue, if the category was added, false for removed
Exceptions
MWException

Definition at line 164 of file CategoryMembershipChange.php.

References $newForCategorizationCallback, $pageTitle, $revision, $timestamp, MediaWiki\Revision\RevisionRecord\getId(), and MediaWiki\Revision\RevisionRecord\getVisibility().

Referenced by createRecentChangesEntry().

◆ overrideNewForCategorizationCallback()

CategoryMembershipChange::overrideNewForCategorizationCallback ( callable  $callback)

Overrides the default new for categorization callback This is intended for use while testing and will fail if MW_PHPUNIT_TEST is not defined.

Parameters
callable$callback
See also
RecentChange::newForCategorization for callback signiture
Exceptions
MWException

Definition at line 97 of file CategoryMembershipChange.php.

◆ triggerCategoryAddedNotification()

CategoryMembershipChange::triggerCategoryAddedNotification ( Title  $categoryTitle)

Create a recentchanges entry for category additions.

Parameters
Title$categoryTitle

Definition at line 116 of file CategoryMembershipChange.php.

References createRecentChangesEntry().

◆ triggerCategoryRemovedNotification()

CategoryMembershipChange::triggerCategoryRemovedNotification ( Title  $categoryTitle)

Create a recentchanges entry for category removals.

Parameters
Title$categoryTitle

Definition at line 125 of file CategoryMembershipChange.php.

References createRecentChangesEntry().

Member Data Documentation

◆ $backlinkCache

BacklinkCache CategoryMembershipChange::$backlinkCache
private

Definition at line 65 of file CategoryMembershipChange.php.

Referenced by __construct().

◆ $newForCategorizationCallback

callable null CategoryMembershipChange::$newForCategorizationCallback = null
private

Definition at line 62 of file CategoryMembershipChange.php.

Referenced by notifyCategorization().

◆ $numTemplateLinks

int CategoryMembershipChange::$numTemplateLinks = 0
private

Number of pages this WikiPage is embedded by Set by CategoryMembershipChange::checkTemplateLinks()

Definition at line 57 of file CategoryMembershipChange.php.

Referenced by getChangeMessageText().

◆ $pageTitle

Title CategoryMembershipChange::$pageTitle
private

Title instance of the categorized page.

Definition at line 45 of file CategoryMembershipChange.php.

Referenced by __construct(), and notifyCategorization().

◆ $revision

RevisionRecord null CategoryMembershipChange::$revision
private

Latest revision of the categorized page.

Definition at line 50 of file CategoryMembershipChange.php.

Referenced by __construct(), and notifyCategorization().

◆ $timestamp

string CategoryMembershipChange::$timestamp
private

Current timestamp, set during CategoryMembershipChange::__construct()

Definition at line 40 of file CategoryMembershipChange.php.

Referenced by notifyCategorization().

◆ CATEGORY_ADDITION

const CategoryMembershipChange::CATEGORY_ADDITION = 1
private

Definition at line 34 of file CategoryMembershipChange.php.

◆ CATEGORY_REMOVAL

const CategoryMembershipChange::CATEGORY_REMOVAL = -1
private

Definition at line 35 of file CategoryMembershipChange.php.


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