Demon has uploaded a new change for review.
https://gerrit.wikimedia.org/r/79025
Change subject: Allow individual search backends to control whether they
SearchUpdate
......................................................................
Allow individual search backends to control whether they SearchUpdate
$wgDisableSearchUpdate is a sledgehammer for disabling all indexing
which is fine for most people, but sometimes you've got multiple
search backends and you want some to update but not others. This
allows each backend to tell core whether they support the feature.
Will require parallel change to MWSearch and possibly SphinxSearch
Change-Id: I2063fe05000044225fa6bec2171ed0071b84a5cf
---
M includes/search/SearchEngine.php
M includes/search/SearchUpdate.php
2 files changed, 26 insertions(+), 19 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/25/79025/1
diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php
index bfe7dda..afa016a 100644
--- a/includes/search/SearchEngine.php
+++ b/includes/search/SearchEngine.php
@@ -95,6 +95,7 @@
public function supports( $feature ) {
switch ( $feature ) {
case 'list-redirects':
+ case 'search-update':
return true;
case 'title-suffix-filter':
default:
diff --git a/includes/search/SearchUpdate.php b/includes/search/SearchUpdate.php
index 7146917..3369543 100644
--- a/includes/search/SearchUpdate.php
+++ b/includes/search/SearchUpdate.php
@@ -89,27 +89,33 @@
wfProfileIn( __METHOD__ );
- $search = SearchEngine::create();
- $normalTitle = $search->normalizeText(
- Title::indexTitle( $this->title->getNamespace(),
$this->title->getText() ) );
+ foreach ( SearchEngine::getSearchTypes() as $type ) {
+ $search = SearchEngine::create( $type );
+ if ( !$search->supports( 'search-update' ) ) {
+ continue;
+ }
- if ( WikiPage::newFromId( $this->id ) === null ) {
- $search->delete( $this->id, $normalTitle );
- wfProfileOut( __METHOD__ );
- return;
- } elseif ( $this->content === false ) {
- $search->updateTitle( $this->id, $normalTitle );
- wfProfileOut( __METHOD__ );
- return;
+ $normalTitle = $search->normalizeText(
+ Title::indexTitle(
$this->title->getNamespace(), $this->title->getText() ) );
+
+ if ( WikiPage::newFromId( $this->id ) === null ) {
+ $search->delete( $this->id, $normalTitle );
+ wfProfileOut( __METHOD__ );
+ return;
+ } elseif ( $this->content === false ) {
+ $search->updateTitle( $this->id, $normalTitle );
+ wfProfileOut( __METHOD__ );
+ return;
+ }
+
+ $text = $search->getTextFromContent( $this->title,
$this->content );
+ if( wfRunHooks( 'SearchUpdate', array( $this->id,
$this->title, &$text, $this->content ) ) ) {
+ $text = self::updateText( $text );
+ }
+
+ # Perform the actual update
+ $search->update( $this->id, $normalTitle,
$search->normalizeText( $text ) );
}
-
- $text = $search->getTextFromContent( $this->title,
$this->content );
- if( wfRunHooks( 'SearchUpdate', array( $this->id, $this->title,
&$text, $this->content ) ) ) {
- $text = self::updateText( $text );
- }
-
- # Perform the actual update
- $search->update( $this->id, $normalTitle,
$search->normalizeText( $text ) );
wfProfileOut( __METHOD__ );
}
--
To view, visit https://gerrit.wikimedia.org/r/79025
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2063fe05000044225fa6bec2171ed0071b84a5cf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Demon <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits