X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FCategoryfinder.php;h=7c1c2856701dbd100a559b1530eec06f84dc6134;hb=8ce84340bf427a65f907bd0e3c1cd907c71860ac;hp=7faae935e82c4ad41e390c204abdd94d9e9bb9f8;hpb=9648f3b4d0f55e0767fd24f3ec2b2b03985d78c0;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Categoryfinder.php b/includes/Categoryfinder.php index 7faae935e8..7c1c285670 100644 --- a/includes/Categoryfinder.php +++ b/includes/Categoryfinder.php @@ -53,9 +53,11 @@ class Categoryfinder { # Set the list of target categories; convert them to DBKEY form first $this->targets = array () ; foreach ( $categories AS $c ) { - $ct = Title::newFromText ( $c , NS_CATEGORY ) ; - $c = $ct->getDBkey () ; - $this->targets[$c] = $c ; + $ct = Title::makeTitleSafe( NS_CATEGORY, $c ); + if( $ct ) { + $c = $ct->getDBkey(); + $this->targets[$c] = $c; + } } } @@ -86,9 +88,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 +128,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 ; @@ -188,5 +196,3 @@ class Categoryfinder { } } # END OF CLASS "Categoryfinder" - -?>