1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-21 22:06:12 +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() { public function loadAllLazyItems() {
if(!$this->useLazy()) return; if(!$this->useLazy()) return;
if(empty($this->lazyItems)) return;
$debug = $this->wire()->config->debug; $debug = $this->wire()->config->debug;
$items = $this->getWireArray(); $items = $this->getWireArray();
$sortable = !empty($this->lazyNameIndex);
foreach(array_keys($this->lazyItems) as $key) { foreach(array_keys($this->lazyItems) as $key) {
if(!isset($this->lazyItems[$key])) continue; // required if(!isset($this->lazyItems[$key])) continue; // required
@@ -869,12 +871,15 @@ abstract class WireSaveableItems extends Wire implements \IteratorAggregate {
if($debug) $item->setQuietly('_lazy', '*'); if($debug) $item->setQuietly('_lazy', '*');
} }
if($sortable) $items->sort('name'); // a-z
$this->lazyItems = array(); $this->lazyItems = array();
$this->lazyNameIndex = array(); $this->lazyNameIndex = array();
$this->lazyIdIndex = 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()); // bd(Debug::backtrace());
// $this->warning(Debug::backtrace());
} }
/** /**