diff --git a/wire/core/Page.php b/wire/core/Page.php index 51639203..06d385a8 100644 --- a/wire/core/Page.php +++ b/wire/core/Page.php @@ -409,7 +409,8 @@ class Page extends WireData implements \Countable, WireMatchable { /** * Field data that queues while the page is loading. * - * Once setIsLoaded(true) is called, this data is processed and instantiated into the Page and the fieldDataQueue is emptied (and no longer relevant) + * Once setIsLoaded(true) is called, this data is processed and instantiated into the Page and + * the fieldDataQueue is emptied (and no longer relevant) * * @var array * @@ -421,7 +422,7 @@ class Page extends WireData implements \Countable, WireMatchable { * * These are most likely field names designated as autoload for this page. * - * @var array of (field name => raw field value) + * @var array of (field name => true) * */ protected $wakeupNameQueue = array(); @@ -3406,11 +3407,11 @@ class Page extends WireData implements \Countable, WireMatchable { * */ public function setIsLoaded($isLoaded, $quiet = false) { + $isLoaded = !$isLoaded || $isLoaded === 'false' ? false : true; if($quiet) { - $this->isLoaded = (bool) $isLoaded; + $this->isLoaded = $isLoaded; return $this; } - $isLoaded = !$isLoaded || $isLoaded === 'false' ? false : true; if($isLoaded) { $this->processFieldDataQueue(); unset(Page::$loadingStack[$this->settings['id']]); @@ -4041,24 +4042,22 @@ class Page extends WireData implements \Countable, WireMatchable { * * #pw-internal * - * @param string|null|array $key String to set one, array to set all, null to get all - * @param mixed $value Value to set if key is string - * @param bool $unset Specify true to unset $key while also specifying null for $value - * @return array|mixed|null + * @param string|null $key String to get or set, omit to get all + * @param bool|null $set Specify true to toggle on, false to toggle off, or omit to get set state + * @return bool|null|array * @since 3.0.205 * */ - public function wakeupNameQueue($key = null, $value = null, $unset = false) { - if($key === null) return $this->wakeupNameQueue; - if($unset) { + public function wakeupNameQueue($key = null, $set = null) { + if($key === null) { + return $this->wakeupNameQueue; + } else if($set === null) { + return isset($this->wakeupNameQueue[$key]); + } else if($set === false) { unset($this->wakeupNameQueue[$key]); - } else if($value !== null) { - $this->wakeupNameQueue[$key] = $value; - } else if(is_array($key)) { - $this->wakeupNameQueue = $key; - } else if(isset($this->wakeupNameQueue[$key])) { - return $this->wakeupNameQueue[$key]; - } + } else if($set) { + $this->wakeupNameQueue[$key] = true; + } return null; } diff --git a/wire/core/PageValues.php b/wire/core/PageValues.php index 988a932b..6f065d95 100644 --- a/wire/core/PageValues.php +++ b/wire/core/PageValues.php @@ -738,6 +738,8 @@ class PageValues extends Wire { $this->setFieldValue($page, $key, $value, false); } + + $page->fieldDataQueue(array()); return true; } @@ -877,14 +879,14 @@ class PageValues extends Wire { $fieldtype = $field->type; $invokeArgument = ''; - if($value !== null && $page->wakeupNameQueue($key) !== null) { + if($value !== null && $page->wakeupNameQueue($key)) { $value = $fieldtype->_callHookMethod('wakeupValue', array($page, $field, $value)); $value = $fieldtype->sanitizeValue($page, $field, $value); - $trackChanges = $this->trackChanges(true); - $this->setTrackChanges(false); + $trackChanges = $page->trackChanges(true); + $page->setTrackChanges(false); $page->_parentSet($key, $value); $page->setTrackChanges($trackChanges); - $page->wakeupNameQueue($key, null, true); + $page->wakeupNameQueue($key, false); } if($field->useRoles && $page->of()) { @@ -908,8 +910,8 @@ class PageValues extends Wire { return $this->formatFieldValue($page, $field, $value); } - $track = $this->trackChanges(); - $this->setTrackChanges(false); + $track = $page->trackChanges(); + $page->setTrackChanges(false); if(!$fieldtype) return null; @@ -943,7 +945,7 @@ class PageValues extends Wire { if(!empty($selector)) $page->__unset($key); if($value instanceof Wire && !$value instanceof Page) $value->resetTrackChanges(true); - if($track) $this->setTrackChanges(true); + if($track) $page->setTrackChanges(true); $value = $this->formatFieldValue($page, $field, $value); @@ -1051,7 +1053,7 @@ class PageValues extends Wire { // if the page is currently loading from the database, we assume that any set values are 'raw' and need to be woken up if(!$page->isLoaded()) { // queue for wakeup and sanitize on first field access - $page->wakeupNameQueue($key, $key); + $page->wakeupNameQueue($key, true); // page is currently loading, so we don't need to continue any further $page->_parentSet($key, $value); return $page; @@ -1062,14 +1064,14 @@ class PageValues extends Wire { // this field is not currently loaded. if the $load param is true, then ... // retrieve old value first in case it's not autojoined so that change comparisons and save's work if($load) $page->get($key); - } else if($page->wakeupNameQueue($key) !== null) { + } else if($page->wakeupNameQueue($key)) { // autoload value: we don't yet have a "woke" value suitable for change detection, so let it wakeup if($page->trackChanges() && $load) { // if changes are being tracked, load existing value for comparison - $this->getFieldValue($page, $this, $key); + $this->getFieldValue($page, $key); } else { // if changes aren't being tracked, the existing value can be discarded - $page->wakeupNameQueue($key, null, true); + $page->wakeupNameQueue($key, false); } } else {