From 0c074a526c832cbb5f44e7c8f0a22d174ac3008f Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Fri, 22 Apr 2011 09:51:35 +0200 Subject: Make ft_pageLookup respect the namespace restriction again Before this change all pages of the given namespace have been included in the result, now the search is restricted to the namespace again as it was before the new indexer has been implemented. --- inc/fulltext.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'inc/fulltext.php') diff --git a/inc/fulltext.php b/inc/fulltext.php index 8155325ee..d2fbabe77 100644 --- a/inc/fulltext.php +++ b/inc/fulltext.php @@ -241,11 +241,11 @@ function _ft_pageLookup(&$data){ } } } + if (isset($ns)) { - foreach ($page_idx as $p_id) { - if (strpos($p_id, $ns) === 0) { - if (!isset($pages[$p_id])) - $pages[$p_id] = p_get_first_heading($p_id, false); + foreach (array_keys($pages) as $p_id) { + if (strpos($p_id, $ns) !== 0) { + unset($pages[$p_id]); } } } -- cgit v1.2.3 From c66f16a3e1edb46da1d29b306c718b775439f5d5 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sat, 23 Apr 2011 00:03:00 +0200 Subject: Make the page lookup by title case insensitive again The page lookup by title has been case insensitive before the indexer rewrite, since then it has been case sensitive, this makes it case insensitive again. --- inc/fulltext.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'inc/fulltext.php') diff --git a/inc/fulltext.php b/inc/fulltext.php index d2fbabe77..fe398feae 100644 --- a/inc/fulltext.php +++ b/inc/fulltext.php @@ -234,8 +234,7 @@ function _ft_pageLookup(&$data){ } } if ($in_title) { - $wildcard_id = "*$id*"; - foreach ($Indexer->lookupKey('title', $wildcard_id) as $p_id) { + foreach ($Indexer->lookupKey('title', $id, '_ft_pageLookupTitleCompare') as $p_id) { if (!isset($pages[$p_id])) $pages[$p_id] = p_get_first_heading($p_id, false); } @@ -264,6 +263,15 @@ function _ft_pageLookup(&$data){ return $pages; } +/** + * Tiny helper function for comparing the searched title with the title + * from the search index. This function is a wrapper around stripos with + * adapted argument order and return value. + */ +function _ft_pageLookupTitleCompare($search, $title) { + return stripos($title, $search) !== false; +} + /** * Sort pages based on their namespace level first, then on their string * values. This makes higher hierarchy pages rank higher than lower hierarchy -- cgit v1.2.3 From 67c15ecea77ff971dcb554de77cf1c25de1140a0 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sun, 8 May 2011 00:51:22 +0200 Subject: Change when metadata is rendered - only when really needed This changes the cache logic for metadata. It introduces a new mode that tries to avoid rendering the page again for simple requests but still updates the metadata when the page has been changed (but not when the cache timeout has been reached or purge is used). It simply compares the time of the last rendering with the last modified time of the page. The old boolean $render parameter has been changed into an int with three possible values. Compatibility for the old parameter is provided using a check with is_numeric using the following mapping: - false is still don't render (0 is the new value for that) - true is using that new render logic which means that many plugins will still work unchanged even if they request a lot of data using $render=true (1 is the new value for that providing full compatibility in the case 1 has been used instead of true) The default value for p_get_first_heading is now that new simple cache logic, the default value for getting metadata is the cache logic which should be used with care but is the only way to request (rendered) metadata that can change because of plugin installations or upgrades. --- inc/fulltext.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/fulltext.php') diff --git a/inc/fulltext.php b/inc/fulltext.php index fe398feae..6ab710d54 100644 --- a/inc/fulltext.php +++ b/inc/fulltext.php @@ -230,13 +230,13 @@ function _ft_pageLookup(&$data){ foreach ($page_idx as $p_id) { if ((strpos($in_ns ? $p_id : noNSorNS($p_id), $cleaned) !== false)) { if (!isset($pages[$p_id])) - $pages[$p_id] = p_get_first_heading($p_id, false); + $pages[$p_id] = p_get_first_heading($p_id, METADATA_DONT_RENDER); } } if ($in_title) { foreach ($Indexer->lookupKey('title', $id, '_ft_pageLookupTitleCompare') as $p_id) { if (!isset($pages[$p_id])) - $pages[$p_id] = p_get_first_heading($p_id, false); + $pages[$p_id] = p_get_first_heading($p_id, METADATA_DONT_RENDER); } } } -- cgit v1.2.3