diff --git a/wire/core/Paths.php b/wire/core/Paths.php index 8a16d7d8..4fe5fd89 100644 --- a/wire/core/Paths.php +++ b/wire/core/Paths.php @@ -8,9 +8,10 @@ * #pw-summary-paths-only These properties are only useful when accessed from `$config->paths` as they are not HTTP accessible as URLs. * #pw-summary-urls-only These properties apply only to the `$urls` or `$config->urls`. Do not use them with `$config->paths`. * #pw-summary-pagination These properties apply only to the `$urls` or `$config->urls` and only when pagination is active for the current request. + * #pw-var $var * * #pw-body = - * The Paths class is used by `$config->paths` and `$config->urls`. The `$config->paths` refers to server disk paths + * The Paths class is used by `$config->paths` and `$config->urls` (or just `$urls`). The `$config->paths` refers to server disk paths * while `$config->urls` refers to web server URLs. All of the same properties are present on both, though several properties * are only useful on one or the other (as outlined below). You can access a path or URL like this: * ~~~~~ @@ -46,6 +47,10 @@ * In the examples on this page, you can replace the `$urls` variable with `$config->paths` if you need to get the server path * instead of a URL. As indicated earlier, `$urls` can aso be accessed at the more verbose `$config->urls` if you prefer. * + * > Please note in the property/method descriptions below that the placeholder `$var` refers to either `$config->paths` or + * `$config->urls` (or the shorter alias `$urls`). So `$var->files` (for example) refers to either `$config->paths->files` + * or `$config->urls->files` (or the shorter alias `$urls->files`). + * * #pw-body * * ProcessWire 3.x, Copyright 2020 by Ryan Cramer diff --git a/wire/core/Template.php b/wire/core/Template.php index 86aa0e9f..097f73fa 100644 --- a/wire/core/Template.php +++ b/wire/core/Template.php @@ -746,14 +746,14 @@ class Template extends WireData implements Saveable, Exportable { */ protected function setSetting($key, $value) { - if($key == 'id') { + if($key === 'id') { $value = (int) $value; - } else if($key == 'name') { - $value = $this->loaded ? $this->wire('sanitizer')->name($value) : $value; + } else if($key === 'name') { + $value = $this->loaded ? $this->wire()->sanitizer->templateName($value) : $value; - } else if($key == 'fieldgroups_id' && $value) { - $fieldgroup = $this->wire('fieldgroups')->get($value); + } else if($key === 'fieldgroups_id' && $value) { + $fieldgroup = $this->wire()->fieldgroups->get($value); if($fieldgroup) { $this->setFieldgroup($fieldgroup); } else { @@ -778,6 +778,28 @@ class Template extends WireData implements Saveable, Exportable { $this->settings[$key] = $value; } + /** + * Set setting value without processing + * + * @param string $key + * @param mixed $value + * @since 3.0.194 + * + */ + public function setRaw($key, $value) { + if($key === 'fieldgroups_id') { + $fieldgroup = $this->wire()->fieldgroups->get($value); + if($fieldgroup) { + $this->settings['fieldgroups_id'] = (int) $value; + $this->fieldgroup = $fieldgroup; + } + } else if(isset($this->settings[$key])) { + $this->settings[$key] = $value; + } else { + parent::set($key, $value); + } + } + /** * Set the cacheExpirePages property * diff --git a/wire/core/Wire.php b/wire/core/Wire.php index 8df58b85..302fe243 100644 --- a/wire/core/Wire.php +++ b/wire/core/Wire.php @@ -974,7 +974,7 @@ abstract class Wire implements WireTranslatable, WireFuelable, WireTrackable { * @var int Bitmask * */ - private $trackChanges = 0; + protected $trackChanges = 0; /** * Array containing the names of properties (as array keys) that were changed while change tracking was ON. diff --git a/wire/core/WireData.php b/wire/core/WireData.php index 7dce3f8c..5e02bc46 100644 --- a/wire/core/WireData.php +++ b/wire/core/WireData.php @@ -63,8 +63,10 @@ class WireData extends Wire implements \IteratorAggregate, \ArrayAccess { if(!is_array($value)) $value = (array) $value; return $this->setArray($value); } - $v = isset($this->data[$key]) ? $this->data[$key] : null; - if(!$this->isEqual($key, $v, $value)) $this->trackChange($key, $v, $value); + if($this->trackChanges) { + $v = isset($this->data[$key]) ? $this->data[$key] : null; + if(!$this->isEqual($key, $v, $value)) $this->trackChange($key, $v, $value); + } $this->data[$key] = $value; return $this; }