Skip to content
Snippets Groups Projects
Commit 5737a81e authored by Michael Hamann's avatar Michael Hamann
Browse files

Revert the search depth behavior changes from #154

This reverts parts of the changes from #154: Before merging the pull
request, a depth of 1 returned just the pages in the root namespace.
With the changes in the pull request, a depth of 1 also returned pages
in subnamespaces of the root namespace (as it was also tested in the test case).
This reverts this part of the changes and a depth of 1 returns just the
pages in the root namespace again.
parent 6416b708
No related branches found
No related tags found
No related merge requests found
......@@ -22,9 +22,9 @@ class search_test extends DokuWikiTest {
search($data, dirname(__FILE__) . '/data', 'search_allpages', array('depth' => 1), 'ns1/ns3');
$this->assertEquals(0, count($data));
//depth is 1 so I should get only pages from ns1
//depth is 2 so I should get only pages from ns1
$data = array();
search($data, dirname(__FILE__) . '/data', 'search_allpages', array('depth' => 1), 'ns1');
search($data, dirname(__FILE__) . '/data', 'search_allpages', array('depth' => 2), 'ns1');
$this->assertEquals(2, count($data));
}
......
......@@ -243,8 +243,8 @@ function search_pagename(&$data,$base,$file,$type,$lvl,$opts){
function search_allpages(&$data,$base,$file,$type,$lvl,$opts){
if(isset($opts['depth']) && $opts['depth']){
$parts = explode('/',ltrim($file,'/'));
if(($type == 'd' && count($parts) > $opts['depth'])
|| ($type != 'd' && count($parts) > $opts['depth'] + 1)){
if(($type == 'd' && count($parts) >= $opts['depth'])
|| ($type != 'd' && count($parts) > $opts['depth'])){
return false; // depth reached
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment