diff --git a/include/class.orm.php b/include/class.orm.php index 7539c144564aba7d5c5922632fe341dc4e9abd9e..74ecc322aa5975416144b7c4e3c1a751c033e650 100644 --- a/include/class.orm.php +++ b/include/class.orm.php @@ -1606,15 +1606,22 @@ extends CachedResultSet { class ModelInstanceManager implements IteratorAggregate { - var $queryset; var $model; var $map; + var $resource; + var $annnotations; + var $defer; static $objectCache = array(); function __construct(QuerySet $queryset) { - $this->queryset = $queryset; $this->model = $queryset->model; + $this->resource = $queryset->getQuery(); + $cache = !$queryset->hasOption(QuerySet::OPT_NOCACHE); + $this->resource->setBuffered($cache); + $this->map = $this->resource->getMap(); + $this->annotations = $queryset->annotations; + $this->defer = $queryset->defer; } function cache($model) { @@ -1669,7 +1676,7 @@ implements IteratorAggregate { return null; } } - $annotations = $this->queryset->annotations; + $annotations = $this->annotations; $extras = array(); // For annotations, drop them from the $fields list and add them to // an $extras list. The fields passed to the root model should only @@ -1688,7 +1695,7 @@ implements IteratorAggregate { // Construct and cache the object $m = $modelClass::$meta->newInstance($fields); // XXX: defer may refer to fields not in this model - $m->__deferred__ = $this->queryset->defer; + $m->__deferred__ = $this->defer; $m->__onload(); if ($cache) $this->cache($m); @@ -1758,10 +1765,6 @@ implements IteratorAggregate { } function getIterator() { - $this->resource = $this->queryset->getQuery(); - $this->map = $this->resource->getMap(); - $cache = !$this->queryset->hasOption(QuerySet::OPT_NOCACHE); - $this->resource->setBuffered($cache); $func = ($this->map) ? 'getRow' : 'getArray'; $func = array($this->resource, $func);