Skip to content

Commit

Permalink
Revert the search depth behavior changes from #154
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
michitux authored and Chris--S committed Feb 24, 2013
1 parent b623501 commit e8baa22
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions _test/tests/inc/search/search.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ function test_search_allpages(){
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));
}

Expand Down
4 changes: 2 additions & 2 deletions inc/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit e8baa22

Please sign in to comment.