[dev] datatree: getObject for nonexistent objects
  Home FAQ Contact Sign in
mailing.www.horde-dev only
 
Advanced search
POPULAR GROUPS

more...

mailing.www.horde-dev Profile…
 Up
[dev] datatree: getObject for nonexistent objects         


Author: Karsten Fourmont
Date: Jan 21, 2007 03:38

Hi,

I just realized that calling DataTree:getObject is extremly costly for
nonexistent objects (with sql backend). If you do this:

$o = $_datatree->getObject("unknown_fake_object");

you'll end up with this sql query being executed:

SELECT [*] FROM horde_datatree c WHERE c.group_uid = 'syncml'

which means that the complete datatree is loaded! Futile as the object
is not there no matter how much you load. (see end of post for detailed
horde.log)

The reason for that as far as I could figure it out:

_buildLoadQuery calls _buildParentIds in line 193 of sql.php:
$parent_where = $this->_buildParentIds($root, $loadTree, 'c.');
_buildParentIds' SQL query does not find anything and so returns '' in
line 267.
Then _buildLoadQuery goes on like this in line 194:
if (!empty($parent_where) && !is_a($parent_where, 'PEAR_Error')) {
$where = sprintf('%%s AND (%%s)', $where, $parent_where);
}
so the where part is not included and the query ends up being "get all".
Show full article (3.64Kb)
no comments