1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-17 20:11:46 +02:00

Minor updates in WireSaveableItems and this should also fix the issue with listing all items not being alpha sorted

This commit is contained in:
Ryan Cramer
2022-02-10 14:03:23 -05:00
parent 598a3a7df5
commit e0fa2c32e3

View File

@@ -858,9 +858,11 @@ abstract class WireSaveableItems extends Wire implements \IteratorAggregate {
public function loadAllLazyItems() {
if(!$this->useLazy()) return;
if(empty($this->lazyItems)) return;
$debug = $this->wire()->config->debug;
$items = $this->getWireArray();
$sortable = !empty($this->lazyNameIndex);
foreach(array_keys($this->lazyItems) as $key) {
if(!isset($this->lazyItems[$key])) continue; // required
@@ -868,13 +870,16 @@ abstract class WireSaveableItems extends Wire implements \IteratorAggregate {
$item = $this->initItem($row, $items);
if($debug) $item->setQuietly('_lazy', '*');
}
if($sortable) $items->sort('name'); // a-z
$this->lazyItems = array();
$this->lazyNameIndex = array();
$this->lazyIdIndex = array();
// if you want to identify what triggered a “load all”, uncomment below:
// if you want to identify what triggered a “load all”, uncomment one of below:
// bd(Debug::backtrace());
// $this->warning(Debug::backtrace());
}
/**