Manybubbles has uploaded a new change for review.
https://gerrit.wikimedia.org/r/168167
Change subject: Add hook to extract namespace in prefix search
......................................................................
Add hook to extract namespace in prefix search
This will allow extensions (namely CirrusSearch) to match namespaces using
their own rules if core can't find the namespace on its own.
Bug: 62322
Change-Id: I17337cd8ce90190bd335c9159e9d3bbb39ba89cd
---
M docs/hooks.txt
M includes/PrefixSearch.php
2 files changed, 12 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/67/168167/1
diff --git a/docs/hooks.txt b/docs/hooks.txt
index 6fb10b1..b71c347 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -2139,6 +2139,13 @@
$limit : maximum number of results to return
&$results : out param: array of page names (strings)
+'PrefixSearchExtractNamespace': Called if core was not able to extract a
+namespace from the search string so that extensions can attempt it.
+$namespaces : array of int namespace keys to search in (change this if you can
+extract namespaces)
+$search : search term (replace this with term without the namespace if you can
+extract one)
+
'PrefsEmailAudit': Called when user changes their email address.
$user: User (object) changing his email address
$oldaddr: old email address (string)
diff --git a/includes/PrefixSearch.php b/includes/PrefixSearch.php
index 5df0ce7..839fedc 100644
--- a/includes/PrefixSearch.php
+++ b/includes/PrefixSearch.php
@@ -60,10 +60,12 @@
$title = Title::newFromText( $search );
if ( $title && !$title->isExternal() ) {
$ns = array( $title->getNamespace() );
+ $search = $title->getText();
if ( $ns[0] == NS_MAIN ) {
$ns = $namespaces; // no explicit prefix, use
default namespaces
+ wfRunHooks( 'PrefixSearchExtractNamespace',
array( &$ns, &$search ) );
}
- return $this->searchBackend( $ns, $title->getText(),
$limit );
+ return $this->searchBackend( $ns, $search, $limit );
}
// Is this a namespace prefix?
@@ -74,6 +76,8 @@
{
$namespaces = array( $title->getNamespace() );
$search = '';
+ } else {
+ wfRunHooks( 'PrefixSearchExtractNamespace', array(
&$namespaces, &$search ) );
}
return $this->searchBackend( $namespaces, $search, $limit );
--
To view, visit https://gerrit.wikimedia.org/r/168167
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I17337cd8ce90190bd335c9159e9d3bbb39ba89cd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Manybubbles <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits