jenkins-bot has submitted this change and it was merged.

Change subject: Properly filter non-core namespaces for interwiki searches
......................................................................


Properly filter non-core namespaces for interwiki searches

According to the InterwikiSearcher constructor we keep only core namespaces
when searching. But Searcher class does not always add the namespace filter.
It tries to optimize the query by counting the expected number of namespaces in
the target index. In the case of interwiki searches the target wiki may contain
extra content namespaces in the content index. It seems more prudent to always
add the namespace filter.
Today this is causing strange behaviors, searching Leonardo Da Vinci on itwiki
will properly display "Autore:Leonardo_da_Vinci" but the link becomes
"Progetto:Leonardo_da_Vinci" which does not exist on itwikisource.
Namespace 102 is Progetto on itwiki but Autore on itwikisource. I suppose that
core does not support specifying namespaces with interwiki links?
Anyways I find the current behaviour misleading, even if it could make sense to
search on content namespaces on the external wiki if I'm searching content
namespaces on the current wiki it seems to me more clear to explicitely always
filter on specific namespaces. Supporting this "content namespaces" behavior 
would
require imo to be explicitely supported in the code.

Change-Id: I1f1ca7c1a2436b4a0a2327b13950c6d03700691d
---
M includes/InterwikiSearcher.php
M includes/Searcher.php
2 files changed, 17 insertions(+), 1 deletion(-)

Approvals:
  EBernhardson: Looks good to me, approved
  jenkins-bot: Verified

Objections:
  Cindy-the-browser-test-bot: There's a problem with this change, please improve



diff --git a/includes/InterwikiSearcher.php b/includes/InterwikiSearcher.php
index c2029a8..bd40dcf 100644
--- a/includes/InterwikiSearcher.php
+++ b/includes/InterwikiSearcher.php
@@ -121,4 +121,20 @@
        protected function getAndFilterExtraIndexes() {
                return array();
        }
+
+       protected function needNsFilter( array $extraIndexes, $indexType ) {
+               // We need to be defensive here, the parent class is not aware
+               // that we plan to search on another wiki. Since we support only
+               // core namespaces we must always add ns filters. This is 
because
+               // content index on the target wiki may contain non-core ns like
+               // Author on wikisource. This is causing troubles in core 
because it
+               // gets confused by namespace id collisions.
+               // The solution could be to use only namespace text and avoid 
setting
+               // namespace id in the result title but anyway I think this is 
misleading
+               // since we do not respect the namespaces filter.
+               // Another approach would be to explicitely support a notion of
+               // "content namespaces" : If I search on content namespaces
+               // then I want to search on content namespaces on this wiki 
aswell.
+               return true;
+       }
 }
diff --git a/includes/Searcher.php b/includes/Searcher.php
index c66db48..99c610b 100644
--- a/includes/Searcher.php
+++ b/includes/Searcher.php
@@ -1341,7 +1341,7 @@
         * @param string $indexType
         * @return boolean
         */
-       private function needNsFilter( array $extraIndexes, $indexType ) {
+       protected function needNsFilter( array $extraIndexes, $indexType ) {
                if ( $extraIndexes ) {
                        // We're reaching into another wiki's indexes and we 
don't know what is there so be defensive.
                        return true;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1f1ca7c1a2436b4a0a2327b13950c6d03700691d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: DCausse <[email protected]>
Gerrit-Reviewer: Cindy-the-browser-test-bot <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Gehel <[email protected]>
Gerrit-Reviewer: Manybubbles <[email protected]>
Gerrit-Reviewer: Smalyshev <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to