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, LoadBalancer $loadBalancer)
 
 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, overwritten files do not seem to trigger LinksUpdateComplete.
 
 onArticleDelete (WikiPage $page, User $user, &$reason, &$error, Status &$status, $suppress)
 Hook to call before an article is deleted.
 
 onArticleDeleteComplete ( $wikiPage, $user, $reason, $id, $content, $logEntry, $archivedRevisionCount)
 Hook to call after an article is deleted.
 
 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.
 
 onArticleUndelete ( $title, $create, $comment, $oldPageId, $restoredPages)
 When article is undeleted - check the archive for other instances of the title, if not there - drop it from the archive.
 

Static Public Member Functions

static create (JobQueueGroup $jobQueue, ConfigFactory $configFactory, LoadBalancer $loadBalancer)
 
static prepareTitlesForLinksUpdate ( $titles, 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.

Constructor & Destructor Documentation

◆ __construct()

CirrusSearch\ChangeListener::__construct ( JobQueueGroup $jobQueue,
SearchConfig $searchConfig,
LoadBalancer $loadBalancer )
Parameters
JobQueueGroup$jobQueue
SearchConfig$searchConfig
LoadBalancer$loadBalancer

Member Function Documentation

◆ create()

static CirrusSearch\ChangeListener::create ( JobQueueGroup $jobQueue,
ConfigFactory $configFactory,
LoadBalancer $loadBalancer )
static

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

◆ onArticleDelete()

CirrusSearch\ChangeListener::onArticleDelete ( WikiPage $page,
User $user,
& $reason,
& $error,
Status & $status,
$suppress )

Hook to call before an article is deleted.

Parameters
WikiPage$pageWikiPage being deleted
User$userUser deleting the article
string&$reasonReason the article is being deleted
string&$errorIf the deletion was prohibited, the (raw HTML) error message to display (added in 1.13)
Status&$statusModify this to throw an error. Overridden by $error (added in 1.20)
bool$suppressWhether this is a suppression deletion or not (added in 1.27)
Returns
bool|void True or no return value to continue or false to abort

◆ onArticleDeleteComplete()

CirrusSearch\ChangeListener::onArticleDeleteComplete ( $wikiPage,
$user,
$reason,
$id,
$content,
$logEntry,
$archivedRevisionCount )

Hook to call after an article is deleted.

Parameters
WikiPage$wikiPageWikiPage that was deleted
User$userUser that deleted the article
string$reasonReason the article was deleted
int$idID of the article that was deleted
\Content | null$contentContent of the deleted page (or null, when deleting a broken page)
\ManualLogEntry$logEntryManualLogEntry used to record the deletion
int$archivedRevisionCountNumber of revisions archived during the deletion
Returns
bool|void True or no return value to continue or false to abort

◆ 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], ... ]

◆ onArticleUndelete()

CirrusSearch\ChangeListener::onArticleUndelete ( $title,
$create,
$comment,
$oldPageId,
$restoredPages )

When article is undeleted - check the archive for other instances of the title, if not there - drop it from the archive.

Parameters
Title$titleTitle corresponding to the article restored
bool$createWhether or not the restoration caused the page to be created (i.e. it didn't exist before)
string$commentComment associated with the undeletion
int$oldPageIdID of page previously deleted (from archive table). This ID will be used for the restored page.
array$restoredPagesSet of page IDs that have revisions restored for this undelete, with keys set to page IDs and values set to 'true'
Returns
bool|void True or no return value to continue or false to abort

◆ onLinksUpdateComplete()

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

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

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

◆ 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

◆ 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, overwritten files do not seem to trigger LinksUpdateComplete.

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

◆ prepareTitlesForLinksUpdate()

static CirrusSearch\ChangeListener::prepareTitlesForLinksUpdate ( $titles,
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
Title[]$titlestitles 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: