84 $this->newForCategorizationCallback = [ RecentChange::class,
'newForCategorization' ];
98 if ( !defined(
'MW_PHPUNIT_TEST' ) ) {
99 throw new MWException(
'Cannot override newForCategorization callback in operation.' );
101 $this->newForCategorizationCallback = $callback;
108 $this->numTemplateLinks = $this->backlinkCache->getNumLinks(
'templatelinks' );
142 $this->pageTitle->getPrefixedText(),
143 $this->numTemplateLinks
146 $this->getPreviousRevisionTimestamp(),
148 $type === self::CATEGORY_ADDITION
166 Title $categoryTitle,
186 # If no revision is given, the change was probably triggered by parser functions
188 $revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
190 $correspondingRc = $revisionStore->getRecentChange( $this->revision );
191 if ( $correspondingRc ===
null ) {
192 $correspondingRc = $revisionStore->getRecentChange(
194 RevisionStore::READ_LATEST
197 if ( $correspondingRc !==
null ) {
198 $bot = $correspondingRc->getAttribute(
'rc_bot' ) ?: 0;
199 $ip = $correspondingRc->getAttribute(
'rc_ip' ) ?:
'';
200 $lastRevId = $correspondingRc->getAttribute(
'rc_last_oldid' ) ?: 0;
234 if ( $this->revision ) {
235 $user = $this->revision->getUser( RevisionRecord::RAW );
241 $username =
wfMessage(
'autochange-username' )->inContentLanguage()->text();
244 if ( $user && !$user->isRegistered() ) {
245 $user->addToDatabase();
248 return $user ?:
null;
269 self::CATEGORY_ADDITION =>
'recentchanges-page-added-to-category',
270 self::CATEGORY_REMOVAL =>
'recentchanges-page-removed-from-category',
273 $msgKey = $array[
$type];
275 if ( intval( $numTemplateLinks ) > 0 ) {
276 $msgKey .=
'-bundled';
279 return wfMessage( $msgKey, $prefixedText )->inContentLanguage()->text();
289 $rl = MediaWikiServices::getInstance()->getRevisionLookup();
290 $latestRev = $rl->getRevisionByTitle( $this->pageTitle );
292 $previousRev = $rl->getPreviousRevision( $latestRev );
293 if ( $previousRev ) {
294 return $previousRev->getTimestamp();
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
if(!defined('MW_SETUP_CALLBACK'))
The persistent session ID (if any) loaded at startup.
Class for fetching backlink lists, approximate backlink counts and partitions.
getPreviousRevisionTimestamp()
Returns the timestamp of the page's previous revision or null if the latest revision does not refer t...
BacklinkCache $backlinkCache
callable null $newForCategorizationCallback
notifyCategorization( $timestamp, Title $categoryTitle, ?UserIdentity $user, $comment, Title $pageTitle, $lastTimestamp, $revision, $added)
getChangeMessageText( $type, $prefixedText, $numTemplateLinks)
Returns the change message according to the type of category membership change.
createRecentChangesEntry(Title $categoryTitle, $type)
Create a recentchanges entry using RecentChange::notifyCategorization()
triggerCategoryRemovedNotification(Title $categoryTitle)
Create a recentchanges entry for category removals.
triggerCategoryAddedNotification(Title $categoryTitle)
Create a recentchanges entry for category additions.
int $numTemplateLinks
Number of pages this WikiPage is embedded by Set by CategoryMembershipChange::checkTemplateLinks()
getUser()
Get the user associated with this change.
string $timestamp
Current timestamp, set during CategoryMembershipChange::__construct()
Title $pageTitle
Title instance of the categorized page.
RevisionRecord null $revision
Latest revision of the categorized page.
overrideNewForCategorizationCallback(callable $callback)
Overrides the default new for categorization callback This is intended for use while testing and will...
__construct(Title $pageTitle, BacklinkCache $backlinkCache, RevisionRecord $revision=null)
checkTemplateLinks()
Determines the number of template links for recursive link updates.
Represents a title within MediaWiki.
static newSystemUser( $name, $options=[])
Static factory method for creation of a "system" user from username.