From: Brion Vibber Date: Mon, 28 Jul 2008 20:59:17 +0000 (+0000) Subject: * Recursion loop check added to Categoryfinder class X-Git-Tag: 1.31.0-rc.0~46318 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/recherche.php?a=commitdiff_plain;h=b878c4fd173201613f83a3ebeb01eafa50413a2b;p=lhc%2Fweb%2Fwiklou.git * Recursion loop check added to Categoryfinder class Infinite loops were causing segfaults in combination with Collection extension --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index b96fbafdf8..bbc2e391a9 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -38,6 +38,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 14659) Passing the default limit param to Special:Recentchanges no more falls back to the user option * (bug 14954) Fix regression in Modern and Simple skins +* Recursion loop check added to Categoryfinder class === API changes in 1.14 === diff --git a/includes/Categoryfinder.php b/includes/Categoryfinder.php index d28f2eebbf..4413bd1acf 100644 --- a/includes/Categoryfinder.php +++ b/includes/Categoryfinder.php @@ -86,9 +86,15 @@ class Categoryfinder { * This functions recurses through the parent representation, trying to match the conditions * @param $id The article/category to check * @param $conds The array of categories to match + * @param $path used to check for recursion loops * @return bool Does this match the conditions? */ - function check ( $id , &$conds ) { + function check ( $id , &$conds, $path=array() ) { + // Check for loops and stop! + if( in_array( $id, $path ) ) + return false; + $path[] = $id; + # Shortcut (runtime paranoia): No contitions=all matched if ( count ( $conds ) == 0 ) return true ; @@ -120,7 +126,7 @@ class Categoryfinder { # No sub-parent continue ; } - $done = $this->check ( $this->name2id[$pname] , $conds ) ; + $done = $this->check ( $this->name2id[$pname] , $conds, $path ); if ( $done OR count ( $conds ) == 0 ) { # Subparents have done it! return true ;