mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-22 04:23:01 +00:00
Bugfix libsearchengine: fix handling of exclusions that are in both the body and the title
This commit is contained in:
parent
1f8b805af3
commit
b4e4094451
2 changed files with 7 additions and 5 deletions
|
@ -42,6 +42,7 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
|
||||||
- Fix the [large blank space problem](https://github.com/sbrl/Pepperminty-Wiki/blob/master/Changelog.md#fixed-3) in all themes
|
- Fix the [large blank space problem](https://github.com/sbrl/Pepperminty-Wiki/blob/master/Changelog.md#fixed-3) in all themes
|
||||||
- Squashed the text `\A` appearing before tags at the bottom of pages for some users ([ref](https://gitter.im/Pepperminty-Wiki/Lobby?at=5f0632068342f4627401f145))
|
- Squashed the text `\A` appearing before tags at the bottom of pages for some users ([ref](https://gitter.im/Pepperminty-Wiki/Lobby?at=5f0632068342f4627401f145))
|
||||||
- Fixed an issue causing uploaded avatars not to render
|
- Fixed an issue causing uploaded avatars not to render
|
||||||
|
- Fixed an obscure bug in the search engine when excluding terms that appear both in a page's title and body
|
||||||
|
|
||||||
|
|
||||||
## v0.21.1-hotfix1
|
## v0.21.1-hotfix1
|
||||||
|
|
|
@ -834,15 +834,17 @@ class search
|
||||||
|
|
||||||
$lit_title = self::$literator->transliterate($pagename);
|
$lit_title = self::$literator->transliterate($pagename);
|
||||||
$lit_tags = isset($pagedata->tags) ? self::$literator->transliterate(implode(" ", $pagedata->tags)) : null;
|
$lit_tags = isset($pagedata->tags) ? self::$literator->transliterate(implode(" ", $pagedata->tags)) : null;
|
||||||
|
$pageid = null; // populated on-demand
|
||||||
|
|
||||||
// Make sure that the title & tags don't contain a term we should exclude
|
// Make sure that the title & tags don't contain a term we should exclude
|
||||||
$skip = false;
|
$skip = false;
|
||||||
foreach($query_stas["exclude"] as $excl_term) {
|
foreach($query_stas["exclude"] as $excl_term) {
|
||||||
if(mb_strpos($lit_title, $excl_term) !== false) {
|
if(mb_strpos($lit_title, $excl_term) !== false) {
|
||||||
$skip = true;
|
$skip = true;
|
||||||
|
if($pageid === null) $pageid = ids::getid($pagename);
|
||||||
// Delete it from the candidate matches (it might be present in the tags / title but not the body)
|
// Delete it from the candidate matches (it might be present in the tags / title but not the body)
|
||||||
if(isset($matching_pages[$excl_term]))
|
if(isset($matching_pages[$pageid]))
|
||||||
unset($matching_pages[$excl_term]);
|
unset($matching_pages[$pageid]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -854,7 +856,7 @@ class search
|
||||||
$title_matches = mb_stripos_all($lit_title, $term_def["term"]);
|
$title_matches = mb_stripos_all($lit_title, $term_def["term"]);
|
||||||
$title_matches_count = $title_matches !== false ? count($title_matches) : 0;
|
$title_matches_count = $title_matches !== false ? count($title_matches) : 0;
|
||||||
if($title_matches_count > 0) {
|
if($title_matches_count > 0) {
|
||||||
$pageid = ids::getid($pagename); // Fetch the page id
|
if($pageid === null) $pageid = ids::getid($pagename);
|
||||||
// We found the qterm in the title
|
// We found the qterm in the title
|
||||||
if(!isset($matching_pages[$pageid]))
|
if(!isset($matching_pages[$pageid]))
|
||||||
$matching_pages[$pageid] = $match_template; // Assign by copy
|
$matching_pages[$pageid] = $match_template; // Assign by copy
|
||||||
|
@ -875,8 +877,7 @@ class search
|
||||||
$tag_matches_count = $tag_matches !== false ? count($tag_matches) : 0;
|
$tag_matches_count = $tag_matches !== false ? count($tag_matches) : 0;
|
||||||
|
|
||||||
if($tag_matches_count > 0) {// And we found the qterm in the tags
|
if($tag_matches_count > 0) {// And we found the qterm in the tags
|
||||||
if($pageid === null) // Fill out the page id if it hasn't been already
|
if($pageid === null) $pageid = ids::getid($pagename);
|
||||||
$pageid = ids::getid($pagename);
|
|
||||||
|
|
||||||
if(!isset($matching_pages[$pageid]))
|
if(!isset($matching_pages[$pageid]))
|
||||||
$matching_pages[$pageid] = $match_template; // Assign by copy
|
$matching_pages[$pageid] = $match_template; // Assign by copy
|
||||||
|
|
Loading…
Reference in a new issue