From 7bb1ca239b4ddd9f8a1632eae19b89e70fce25ed Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Mon, 18 Jun 2018 09:35:12 +0200 Subject: [PATCH] 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. --- t/search-inclusion.t | 23 +++++++++++++++++++++++ t/search.t | 4 ++-- wiki.pl | 2 +- 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 t/search-inclusion.t diff --git a/t/search-inclusion.t b/t/search-inclusion.t new file mode 100644 index 00000000..ab5ac6d0 --- /dev/null +++ b/t/search-inclusion.t @@ -0,0 +1,23 @@ +# Copyright (C) 2018 Alex Schroeder +# +# 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 . + +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"), + "Omega"); +test_page(get_page('Omega'), 'last page'); diff --git a/t/search.t b/t/search.t index 744ae48f..58a694fc 100644 --- a/t/search.t +++ b/t/search.t @@ -1,4 +1,4 @@ -# Copyright (C) 2006–2015 Alex Schroeder +# Copyright (C) 2006–2018 Alex Schroeder # # 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"]'); diff --git a/wiki.pl b/wiki.pl index 27a5597a..898c89ab 100644 --- a/wiki.pl +++ b/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});