From d0bdf7659fce98c2922b151766d51d5c7e8814d6 Mon Sep 17 00:00:00 2001
From: Adrian Lang <lang@cosmocode.de>
Date: Fri, 20 Aug 2010 18:53:48 +0200
Subject: [PATCH] Use namespace filter in quicksearch with empty search term

---
 inc/fulltext.php | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/inc/fulltext.php b/inc/fulltext.php
index 1c9981812..cac2de4a4 100644
--- a/inc/fulltext.php
+++ b/inc/fulltext.php
@@ -243,17 +243,21 @@ function _ft_pageLookup(&$data){
     $titles = array_map('rtrim', idx_getIndex('title', ''));
     $pages = array_combine($pages, $titles);
 
-    if($id !== '' && cleanID($id) !== '') {
+    if ($id !== '' && cleanID($id) !== '') {
         $cleaned = cleanID($id);
-        $matched_pages = array();
         foreach ($pages as $p_id => $p_title) {
-            if (((strpos($in_ns ? $p_id : noNSorNS($p_id), $cleaned) !== false) ||
-                 ($in_title && stripos($p_title, $id) !== false)) &&
-                (!isset($ns) || strpos($p_id, $ns) === 0)) {
-                $matched_pages[$p_id] = $p_title;
+            if ((strpos($in_ns ? $p_id : noNSorNS($p_id), $cleaned) === false) &&
+                ($in_title && stripos($p_title, $id) === false)) {
+                unset($pages[$p_id]);
+            }
+        }
+    }
+    if (isset($ns)) {
+        foreach (array_keys($pages) as $p_id) {
+            if (strpos($p_id, $ns) !== 0) {
+                unset($pages[$p_id]);
             }
         }
-        $pages = $matched_pages;
     }
 
     // discard hidden pages
-- 
GitLab