diff options
author | Guillaume Turri <guillaume.turri@gmail.com> | 2013-01-09 22:26:22 +0100 |
---|---|---|
committer | Guillaume Turri <guillaume.turri@gmail.com> | 2013-01-09 22:49:35 +0100 |
commit | c647387e09a52c1a67a72b8923ca4de06f8555cf (patch) | |
tree | 803f1d60526a6fdc9fd3285591593992e81d1429 | |
parent | e47e9c10c754a8b04f2f5fb07877e55863ffdea5 (diff) | |
download | rpg-c647387e09a52c1a67a72b8923ca4de06f8555cf.tar.gz rpg-c647387e09a52c1a67a72b8923ca4de06f8555cf.tar.bz2 |
Check search limit depth with an inequality
Otherwise, when we check for equality, the test fails if the search start beneath
the max depth.
Eg: if I have the page ns1:ns2:mypage in my wiki, and launch the xmlrpc query
getPagelist("ns1", "depth => 1"), without this patch, it retrieves mypage
-rw-r--r-- | inc/search.php | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/inc/search.php b/inc/search.php index 1cecfd5ec..e18777063 100644 --- a/inc/search.php +++ b/inc/search.php @@ -247,11 +247,16 @@ function search_pagename(&$data,$base,$file,$type,$lvl,$opts){ * @author Andreas Gohr <andi@splitbrain.org> */ function search_allpages(&$data,$base,$file,$type,$lvl,$opts){ + if(isset($opts['depth'])){ + $parts = explode('/',ltrim($file,'/')); + if(($type == 'd' && count($parts) > $opts['depth']) + || ($type != 'd' && count($parts) > $opts['depth'] + 1)){ + return false; // depth reached + } + } + //we do nothing with directories if($type == 'd'){ - if(!$opts['depth']) return true; // recurse forever - $parts = explode('/',ltrim($file,'/')); - if(count($parts) == $opts['depth']) return false; // depth reached return true; } |