yanwong / ganon

Automatically exported from code.google.com/p/ganon
0 stars 0 forks source link

Call to a member function match() on a non-object in ganon.php on line 1551 #66

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The problem cames when there is bad nodes.

The solution : 

function getChildrenByMatch($conditions, $recursive = true, $check_self = 
false, $custom_filters = array()) {
        $count = $this->childCount();
        if ($check_self && $this->match($conditions, true, $custom_filters)) {
            $res = array($this);
        } else {
            $res = array();
        }
        if ($count > 0) {
            if (is_int($recursive)) {
                $recursive = (($recursive > 1) ? $recursive - 1 : false);
            }
            for ($i = 0; $i < $count; $i++) {
                ++if (!isset($this->children[$i]))
                ++  continue;

                if ($this->children[$i]->match($conditions, true, $custom_filters)) {
                    $res[] = $this->children[$i];
                }
                if ($recursive) {
                    $res = array_merge($res, $this->children[$i]->getChildrenByMatch($conditions, $recursive, false, $custom_filters));
                }
            }
        }
        return $res;
    }

Thanks for this library

Original issue reported on code.google.com by Alel...@gmail.com on 26 Nov 2014 at 1:59

GoogleCodeExporter commented 8 years ago
And there is too :

L 1020 :

function clear() {
        foreach($this->children as $c) {
            ++if (!isset($c))
            ++  continue;

            $c->parent = null;
            $c->delete();
        }
        $this->children = array();
    }

Original comment by Alel...@gmail.com on 26 Nov 2014 at 2:09