forked from github/kensanata.oddmuse
search-inclusion: new test and fix
I must have misunderstood how 'local' works because it turns out that you need to move it out of the block for it to work as intended.
This commit is contained in:
23
t/search-inclusion.t
Normal file
23
t/search-inclusion.t
Normal file
@@ -0,0 +1,23 @@
|
||||
# Copyright (C) 2018 Alex Schroeder <alex@gnu.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require './t/test.pl';
|
||||
package OddMuse;
|
||||
use Test::More tests => 3;
|
||||
|
||||
test_page(update_page("Omega", "last page"), "last page");
|
||||
test_page(update_page("Alpha", "first page\n<search page>"),
|
||||
"Omega");
|
||||
test_page(get_page('Omega'), 'last page');
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2006–2015 Alex Schroeder <alex@gnu.org>
|
||||
# Copyright (C) 2006–2018 Alex Schroeder <alex@gnu.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -156,7 +156,7 @@ xpath_test(update_page('IncludeSearch',
|
||||
'//p[text()="first line "]', # note the NL -> SPC
|
||||
'//div[@class="search"]/p/span[@class="result"]/a[@class="local"][@href="http://localhost/wiki.pl/NegativeSearchTest"][text()="NegativeSearchTest"]',
|
||||
'//div[@class="search"]/p/span[@class="result"]/a[@class="local"][@href="http://localhost/wiki.pl/NegativeSearchTestTwo"][text()="NegativeSearchTestTwo"]',
|
||||
'//p[text()=" last line"]'); # note the NL -> SPC
|
||||
'//p[text()=" last line"]'); # note the NL -> SPC
|
||||
|
||||
xpath_test(get_page('search=Schröder'),
|
||||
'//input[@name="search"][@value="Schröder"]');
|
||||
|
||||
2
wiki.pl
2
wiki.pl
@@ -3484,8 +3484,8 @@ sub SearchTitleAndBody {
|
||||
foreach my $id (Filtered($regex, AllPagesList())) {
|
||||
my $name = NormalToFree($id);
|
||||
my ($text) = PageIsUploadedFile($id); # set to mime-type if this is an uploaded file
|
||||
local ($OpenPageName, %Page); # this is local!
|
||||
if (not $text) { # not uploaded file, therefore allow searching of page body
|
||||
local ($OpenPageName, %Page); # this is local!
|
||||
OpenPage($id); # this opens a page twice if it is not uploaded, but that's ok
|
||||
if ($lang) {
|
||||
my @languages = split(/,/, $Page{languages});
|
||||
|
||||
Reference in New Issue
Block a user