Demon has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/69515


Change subject: Allow SearchUpdate hook to abort core update call
......................................................................

Allow SearchUpdate hook to abort core update call

No extension actually uses this hook yet.

Change-Id: I09d11b81c224d53609c57d75d54021e697b56629
---
M includes/search/SearchUpdate.php
1 file changed, 17 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/15/69515/1

diff --git a/includes/search/SearchUpdate.php b/includes/search/SearchUpdate.php
index 759c7b9..b848440 100644
--- a/includes/search/SearchUpdate.php
+++ b/includes/search/SearchUpdate.php
@@ -65,22 +65,27 @@
                $search = SearchEngine::create();
                $normalTitle = $search->normalizeText( Title::indexTitle( 
$this->mNamespace, $this->mTitle ) );
 
+               $action = 'update';
                if ( WikiPage::newFromId( $this->mId ) === null ) {
-                       $search->delete( $this->mId, $normalTitle );
-                       wfProfileOut( __METHOD__ );
-                       return;
+                       $action = 'delete';
                } elseif ( $this->mText === false ) {
-                       $search->updateTitle( $this->mId, $normalTitle );
-                       wfProfileOut( __METHOD__ );
-                       return;
+                       $action = 'updateTitle';
                }
 
-               $text = self::updateText( $this->mText );
-
-               wfRunHooks( 'SearchUpdate', array( $this->mId, 
$this->mNamespace, $this->mTitle, &$text ) );
-
-               # Perform the actual update
-               $search->update( $this->mId, $normalTitle, 
$search->normalizeText( $text ) );
+               if( wfRunHooks( 'SearchUpdate', array( $this->mId, 
$this->mNamespace, $this->mTitle, &$text ) ) ) {
+                       switch ( $action ) {
+                               # Simple delete/title update case
+                               case 'delete':
+                               case 'updateTitle';
+                                       $search->$action( $this->mId, 
$normalTitle );
+                                       break;
+                               default:
+                                       # Perform the actual update
+                                       $text = self::updateText( $this->mText 
);
+                                       $search->update( $this->mId, 
$normalTitle, $search->normalizeText( $text ) );
+                                       break;
+                       }
+               }
 
                wfProfileOut( __METHOD__ );
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/69515
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I09d11b81c224d53609c57d75d54021e697b56629
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

Reply via email to