mirror of
https://github.com/processwire/processwire.git
synced 2025-08-10 16:54:44 +02:00
Fix inadvertent debug mode memory leak issue when using $pages->findMany(), plus optimize PageTable for faster load when sortfield(s) are in use. Per @apeisa / Avoine.
This commit is contained in:
@@ -121,10 +121,11 @@ class PageArrayIterator extends Wire implements \Iterator {
|
|||||||
$ids[] = $page->id;
|
$ids[] = $page->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$debug = $this->wire('pages');
|
$pages = $this->wire('pages');
|
||||||
if($debug) $this->wire('pages')->debug(false);
|
$debug = $pages->debug();
|
||||||
$this->pages = $this->wire('pages')->getById($ids, $options);
|
if($debug) $pages->debug(false);
|
||||||
if($debug) $this->wire('pages')->debug(true);
|
$this->pages = $pages->getById($ids, $options);
|
||||||
|
if($debug) $pages->debug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->pagesCount = count($this->pages);
|
$this->pagesCount = count($this->pages);
|
||||||
|
@@ -405,25 +405,17 @@ class FieldtypePageTable extends FieldtypeMulti implements Module {
|
|||||||
$loadOptions = array('cache' => false);
|
$loadOptions = array('cache' => false);
|
||||||
if($template) $loadOptions['template'] = $template;
|
if($template) $loadOptions['template'] = $template;
|
||||||
|
|
||||||
$sortfields = $field->get('sortfields');
|
$items = $this->wire('pages')->getById($value, $loadOptions);
|
||||||
|
|
||||||
|
$sortfields = $field->get('sortfields');
|
||||||
if($sortfields) {
|
if($sortfields) {
|
||||||
$selector = $template ? "template=$template, " : "";
|
$sorts = array();
|
||||||
$selector .= "include=unpublished, id=" . implode('|', $value);
|
|
||||||
foreach(explode(',', $sortfields) as $sortfield) {
|
foreach(explode(',', $sortfields) as $sortfield) {
|
||||||
$selector .= ", sort=" . $this->wire('sanitizer')->name(trim($sortfield));
|
$sorts[] = $this->wire('sanitizer')->name(trim($sortfield));
|
||||||
}
|
}
|
||||||
$options = array(
|
if(count($sorts)) $items->sort($sorts);
|
||||||
'cache' => false,
|
|
||||||
'caller' => $this->className() . '::wakeupValue',
|
|
||||||
'loadOptions' => $loadOptions
|
|
||||||
);
|
|
||||||
$items = $this->wire('pages')->find($selector, $options);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
$items = $this->wire('pages')->getById($value, $loadOptions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user