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();
245 # User::newFromName() can return false on a badly configured wiki.
246 if ( $user && !$user->isRegistered() ) {
247 $user->addToDatabase();
250 return $user ?:
null;
271 self::CATEGORY_ADDITION =>
'recentchanges-page-added-to-category',
272 self::CATEGORY_REMOVAL =>
'recentchanges-page-removed-from-category',
275 $msgKey = $array[
$type];
277 if ( intval( $numTemplateLinks ) > 0 ) {
278 $msgKey .=
'-bundled';
281 return wfMessage( $msgKey, $prefixedText )->inContentLanguage()->text();
291 $rl = MediaWikiServices::getInstance()->getRevisionLookup();
292 $latestRev = $rl->getRevisionByTitle( $this->pageTitle );
294 $previousRev = $rl->getPreviousRevision( $latestRev );
295 if ( $previousRev ) {
296 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(ini_get('mbstring.func_overload')) if(!defined('MW_ENTRY_POINT'))
Pre-config setup: Before loading LocalSettings.php.
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 newFromName( $name, $validate='valid')