CirrusSearch
Elasticsearch-powered search for MediaWiki
Loading...
Searching...
No Matches
CirrusSearch\ChangeListener Class Reference

Implementation to all the hooks that CirrusSearch needs to listen in order to keep its index in sync with main SQL database. More...

+ Inheritance diagram for CirrusSearch\ChangeListener:
+ Collaboration diagram for CirrusSearch\ChangeListener:

Public Member Functions

 __construct (JobQueueGroup $jobQueue, SearchConfig $searchConfig, IConnectionProvider $dbProvider, RedirectLookup $redirectLookup)
 
 onArticleRevisionVisibilitySet ( $title, $ids, $visibilityChangeMap)
 Called when a revision is deleted.
 
 onLinksUpdateComplete ( $linksUpdate, $ticket)
 Hooked to update the search index when pages change directly or when templates that they include change.
 
 onUploadComplete ( $uploadBase)
 Hook into UploadComplete, because overwritten files mistakenly do not trigger LinksUpdateComplete (T344285).
 
 onPageDelete (ProperPageIdentity $page, Authority $deleter, string $reason, \StatusValue $status, bool $suppress)
 This hook is called before a page is deleted.
 
 onPageDeleteComplete (ProperPageIdentity $page, Authority $deleter, string $reason, int $pageID, RevisionRecord $deletedRev, ManualLogEntry $logEntry, int $archivedRevisionCount)
 
 onTitleMove (Title $old, Title $nt, User $user, $reason, Status &$status)
 Before we've moved a title from $title to $newTitle.
 
 onPageMoveComplete ( $old, $new, $user, $pageid, $redirid, $reason, $revision)
 When we've moved a Title from A to B.
 
- Public Member Functions inherited from CirrusSearch\PageChangeTracker
 __construct (int $maxStateSize=512)
 
 onPageDelete (ProperPageIdentity $page, Authority $deleter, string $reason, StatusValue $status, bool $suppress)
 
 onPageSaveComplete ( $wikiPage, $user, $summary, $flags, $revisionRecord, $editResult)
 
 isPageChange (int $pageId)
 Test if this pageId was references in a hook call earlier.
 

Static Public Member Functions

static create (JobQueueGroup $jobQueue, ConfigFactory $configFactory, IConnectionProvider $dbProvider, RedirectLookup $redirectLookup)
 
static preparePageReferencesForLinksUpdate ( $pageReferences, int $max, $excludeBadUTF=false)
 Take a list of titles either linked or unlinked and prepare them for Job\LinksUpdate.
 

Detailed Description

Implementation to all the hooks that CirrusSearch needs to listen in order to keep its index in sync with main SQL database.

Member Function Documentation

◆ create()

static CirrusSearch\ChangeListener::create ( JobQueueGroup $jobQueue,
ConfigFactory $configFactory,
IConnectionProvider $dbProvider,
RedirectLookup $redirectLookup )
static

@phan-suppress-next-line PhanTypeMismatchArgumentSuperType $config is actually a SearchConfig

◆ onArticleRevisionVisibilitySet()

CirrusSearch\ChangeListener::onArticleRevisionVisibilitySet ( $title,
$ids,
$visibilityChangeMap )

Called when a revision is deleted.

In theory, we shouldn't need to to this since you can't delete the current text of a page (so we should've already updated when the page was updated last). But we're paranoid, because deleted revisions absolutely should not be in the index.

Parameters
Title$titleThe page title we've had a revision deleted on
int[]$idsIDs to set the visibility for
array$visibilityChangeMapMap of revision ID to oldBits and newBits. This array can be examined to determine exactly what visibility bits have changed for each revision. This array is of the form: [id => ['oldBits' => $oldBits, 'newBits' => $newBits], ... ]

◆ onLinksUpdateComplete()

CirrusSearch\ChangeListener::onLinksUpdateComplete ( $linksUpdate,
$ticket )

Hooked to update the search index when pages change directly or when templates that they include change.

Parameters
\MediaWiki\Deferred\LinksUpdate\LinksUpdate$linksUpdate
mixed$ticketPrior result of LBFactory::getEmptyTransactionTicket()

◆ onPageDelete()

CirrusSearch\ChangeListener::onPageDelete ( ProperPageIdentity $page,
Authority $deleter,
string $reason,
\StatusValue $status,
bool $suppress )

This hook is called before a page is deleted.

Since
1.37
Parameters
ProperPageIdentity$pagePage being deleted.
Authority$deleterWho is deleting the page
string$reasonReason the page is being deleted
\StatusValue$statusAdd any error here
bool$suppressWhether this is a suppression deletion or not
Returns
bool|void True or no return value to continue; false to abort, which also requires adding a fatal error to $status.

◆ onPageDeleteComplete()

CirrusSearch\ChangeListener::onPageDeleteComplete ( ProperPageIdentity $page,
Authority $deleter,
string $reason,
int $pageID,
RevisionRecord $deletedRev,
ManualLogEntry $logEntry,
int $archivedRevisionCount )
Parameters
ProperPageIdentity$page
Authority$deleter
string$reason
int$pageID
RevisionRecord$deletedRev
ManualLogEntry$logEntry
int$archivedRevisionCount
Returns
void

Reimplemented from CirrusSearch\PageChangeTracker.

◆ onPageMoveComplete()

CirrusSearch\ChangeListener::onPageMoveComplete ( $old,
$new,
$user,
$pageid,
$redirid,
$reason,
$revision )

When we've moved a Title from A to B.

Parameters
\MediaWiki\Linker\LinkTarget$oldOld title
\MediaWiki\Linker\LinkTarget$newNew title
\MediaWiki\User\UserIdentity$userUser who did the move
int$pageidDatabase ID of the page that's been moved
int$rediridDatabase ID of the created redirect
string$reasonReason for the move
\MediaWiki\Revision\RevisionRecord$revisionRevisionRecord created by the move
Returns
bool|void True or no return value to continue or false stop other hook handlers, doesn't abort the move itself

Reimplemented from CirrusSearch\PageChangeTracker.

◆ onTitleMove()

CirrusSearch\ChangeListener::onTitleMove ( Title $old,
Title $nt,
User $user,
$reason,
Status & $status )

Before we've moved a title from $title to $newTitle.

Parameters
Title$oldOld title
Title$ntNew title
User$userUser who does the move
string$reasonReason provided by the user
Status&$statusTo abort the move, add a fatal error to this object (i.e. call $status->fatal())
Returns
bool|void True or no return value to continue or false to abort

◆ onUploadComplete()

CirrusSearch\ChangeListener::onUploadComplete ( $uploadBase)

Hook into UploadComplete, because overwritten files mistakenly do not trigger LinksUpdateComplete (T344285).

Since files do contain indexed metadata we need to refresh the search index when a file is overwritten on an existing title.

Parameters
\UploadBase$uploadBase

◆ preparePageReferencesForLinksUpdate()

static CirrusSearch\ChangeListener::preparePageReferencesForLinksUpdate ( $pageReferences,
int $max,
$excludeBadUTF = false )
static

Take a list of titles either linked or unlinked and prepare them for Job\LinksUpdate.

This includes limiting them to $max titles.

Parameters
PageReference[]$pageReferencestitles to prepare
int$maxmaximum number of titles to return
bool$excludeBadUTFexclude links that contains invalid UTF sequences
Returns
array

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