From c647387e09a52c1a67a72b8923ca4de06f8555cf Mon Sep 17 00:00:00 2001 From: Guillaume Turri Date: Wed, 9 Jan 2013 22:26:22 +0100 Subject: 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 --- inc/search.php | 11 ++++++++--- 1 file 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 */ 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; } -- cgit v1.2.3