Skip to content
Snippets Groups Projects
Unverified Commit 22cb8611 authored by Peter Rotich's avatar Peter Rotich Committed by GitHub
Browse files

Merge pull request #4247 from greezybacon/issue/orm-fixes

orm: queryset: Fix circular reference error
parents fb603a3f 0f9cab06
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment