Subversion Repositories oidplus

Compare Revisions

Regard whitespace Rev 1460 → Rev 1461

/trunk/includes/classes/OIDplusObject.class.php
762,8 → 762,13
*/
public function equals($obj): bool {
if (!$obj) return false;
if (!is_object($obj)) $obj = OIDplusObject::parse($obj);
if (!is_object($obj)) {
if ($this->nodeId(true) === $obj) return true; // simplest case
$obj = OIDplusObject::parse($obj);
if (!$obj) return false;
} else {
if ($this->nodeId(true) === $obj->nodeId(true)) return true; // simplest case
}
if (!($obj instanceof $this)) return false;
 
$distance = $this->distance($obj);
781,11 → 786,13
$obj = OIDplusObject::parse($search_id);
if (!$obj) return false; // e.g. if ObjectType plugin is disabled
 
if ($obj->nodeId(false) == '') return false; // speed optimization. "oid:" is not equal to any object in the database
 
if (!OIDplus::baseConfig()->getValue('OBJECT_CACHING', true)) {
$res = OIDplus::db()->query("select id from ###objects where id like ?", array($obj->ns().':%'));
while ($row = $res->fetch_object()) {
$test = OIDplusObject::parse($row->id);
if ($obj->equals($test)) return $test;
if ($test && $obj->equals($test)) return $test;
}
return false;
} else {
793,7 → 800,7
foreach (self::$object_info_cache as $id => $cacheitem) {
if (strpos($id, $obj->ns().':') === 0) {
$test = OIDplusObject::parse($id);
if ($obj->equals($test)) return $test;
if ($test && $obj->equals($test)) return $test;
}
}
return false;
/trunk/includes/classes/OIDplusQueryResult.class.php
136,7 → 136,8
if (!$this->containsResultSet()) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)'));
if (!is_null($this->prefetchedArray)) {
// Prefetched value exists. Use it.
$ary = array_shift($this->prefetchedArray);
//$ary = array_shift($this->prefetchedArray);
$ary = $this->prefetchedArray[$this->countAlreadyFetched] ?? null; // Performance is better this way
} else {
$reflector = new \ReflectionMethod($this, 'do_fetch_array');
$isImplemented = ($reflector->getDeclaringClass()->getName() !== self::class);
180,7 → 181,8
if (!$this->containsResultSet()) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)'));
if (!is_null($this->prefetchedArray)) {
// Prefetched value exists (as array). Convert and use it.
$ary = array_shift($this->prefetchedArray);
//$ary = array_shift($this->prefetchedArray);
$ary = $this->prefetchedArray[$this->countAlreadyFetched] ?? null; // Performance is better this way
$obj = is_null($ary) ? null : array_to_stdobj($ary);
} else {
$reflector = new \ReflectionMethod($this, 'do_fetch_object');