76 $this->newForCategorizationCallback = [ RecentChange::class,
'newForCategorization' ];
89 if ( !defined(
'MW_PHPUNIT_TEST' ) ) {
90 throw new MWException(
'Cannot override newForCategorization callback in operation.' );
92 $this->newForCategorizationCallback = $callback;
99 $this->numTemplateLinks = $this->pageTitle->getBacklinkCache()->getNumLinks(
'templatelinks' );
133 $this->pageTitle->getPrefixedText(),
134 $this->numTemplateLinks
137 $this->getPreviousRevisionTimestamp(),
139 $type === self::CATEGORY_ADDITION
157 Title $categoryTitle,
177 # If no revision is given, the change was probably triggered by parser functions
179 $correspondingRc = $this->revision->getRecentChange();
180 if ( $correspondingRc ===
null ) {
181 $correspondingRc = $this->revision->getRecentChange( Revision::READ_LATEST );
183 if ( $correspondingRc !==
null ) {
184 $bot = $correspondingRc->getAttribute(
'rc_bot' ) ?: 0;
185 $ip = $correspondingRc->getAttribute(
'rc_ip' ) ?:
'';
186 $lastRevId = $correspondingRc->getAttribute(
'rc_last_oldid' ) ?: 0;
220 if ( $this->revision ) {
221 $userId = $this->revision->getUser( RevisionRecord::RAW );
222 if ( $userId === 0 ) {
223 return User::newFromName( $this->revision->getUserText( RevisionRecord::RAW ),
false );
229 $username =
wfMessage(
'autochange-username' )->inContentLanguage()->text();
231 # User::newFromName() can return false on a badly configured wiki.
232 if ( $user && !$user->isLoggedIn() ) {
233 $user->addToDatabase();
257 self::CATEGORY_ADDITION =>
'recentchanges-page-added-to-category',
258 self::CATEGORY_REMOVAL =>
'recentchanges-page-removed-from-category',
261 $msgKey = $array[
$type];
264 $msgKey .=
'-bundled';
267 return wfMessage( $msgKey, $prefixedText )->inContentLanguage()->text();
277 $rl = MediaWikiServices::getInstance()->getRevisionLookup();
278 $latestRev = $rl->getRevisionByTitle( $this->pageTitle );
280 $previousRev = $rl->getPreviousRevision( $latestRev );
281 if ( $previousRev ) {
282 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.
getPreviousRevisionTimestamp()
Returns the timestamp of the page's previous revision or null if the latest revision does not refer t...
callable null $newForCategorizationCallback
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()
__construct(Title $pageTitle, Revision $revision=null)
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()
Revision null $revision
Latest Revision instance of the categorized page.
Title $pageTitle
Title instance of the categorized page.
notifyCategorization( $timestamp, Title $categoryTitle, User $user=null, $comment, Title $pageTitle, $lastTimestamp, $revision, $added)
overrideNewForCategorizationCallback(callable $callback)
Overrides the default new for categorization callback This is intended for use while testing and will...
checkTemplateLinks()
Determines the number of template links for recursive link updates.
getVisibility()
Get the deletion bitfield of the revision.
Represents a title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
static newFromId( $id)
Static factory method for creation from a given user ID.