mirror of
https://github.com/processwire/processwire.git
synced 2025-08-10 16:54:44 +02:00
Attempt fix for issue #58 where saving user with different parent than default could result in unnecessary pages_parents table updates.
This commit is contained in:
@@ -1654,8 +1654,10 @@ class Page extends WireData implements \Countable, WireMatchable {
|
|||||||
protected function setTemplate($tpl) {
|
protected function setTemplate($tpl) {
|
||||||
if(!is_object($tpl)) $tpl = $this->wire('templates')->get($tpl);
|
if(!is_object($tpl)) $tpl = $this->wire('templates')->get($tpl);
|
||||||
if(!$tpl instanceof Template) throw new WireException("Invalid value sent to Page::setTemplate");
|
if(!$tpl instanceof Template) throw new WireException("Invalid value sent to Page::setTemplate");
|
||||||
if($this->template && $this->template->id != $tpl->id) {
|
if($this->template && $this->template->id != $tpl->id && $this->isLoaded) {
|
||||||
if($this->settings['status'] & Page::statusSystem) throw new WireException("Template changes are disallowed on this page");
|
if($this->settings['status'] & Page::statusSystem) {
|
||||||
|
throw new WireException("Template changes are disallowed on this page");
|
||||||
|
}
|
||||||
if(is_null($this->templatePrevious)) $this->templatePrevious = $this->template;
|
if(is_null($this->templatePrevious)) $this->templatePrevious = $this->template;
|
||||||
$this->trackChange('template', $this->template, $tpl);
|
$this->trackChange('template', $this->template, $tpl);
|
||||||
}
|
}
|
||||||
@@ -1680,10 +1682,14 @@ class Page extends WireData implements \Countable, WireMatchable {
|
|||||||
if($parent->id && $this->id == $parent->id || $parent->parents->has($this)) {
|
if($parent->id && $this->id == $parent->id || $parent->parents->has($this)) {
|
||||||
throw new WireException("Page cannot be its own parent");
|
throw new WireException("Page cannot be its own parent");
|
||||||
}
|
}
|
||||||
$this->trackChange('parent', $this->parent, $parent);
|
if($this->isLoaded) {
|
||||||
if(($this->parent && $this->parent->id) && $this->parent->id != $parent->id) {
|
$this->trackChange('parent', $this->parent, $parent);
|
||||||
if($this->settings['status'] & Page::statusSystem) throw new WireException("Parent changes are disallowed on this page");
|
if(($this->parent && $this->parent->id) && $this->parent->id != $parent->id) {
|
||||||
$this->parentPrevious = $this->parent;
|
if($this->settings['status'] & Page::statusSystem) {
|
||||||
|
throw new WireException("Parent changes are disallowed on this page");
|
||||||
|
}
|
||||||
|
if(is_null($this->parentPrevious)) $this->parentPrevious = $this->parent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$this->parent = $parent;
|
$this->parent = $parent;
|
||||||
return $this;
|
return $this;
|
||||||
|
@@ -879,7 +879,10 @@ class PagesEditor extends Wire {
|
|||||||
} while(1);
|
} while(1);
|
||||||
|
|
||||||
if($insertSql) {
|
if($insertSql) {
|
||||||
$sql = "INSERT INTO pages_parents (pages_id, parents_id) VALUES" . rtrim($insertSql, ",");
|
$sql =
|
||||||
|
'INSERT INTO pages_parents (pages_id, parents_id) ' .
|
||||||
|
'VALUES' . rtrim($insertSql, ',') . ' ' .
|
||||||
|
'ON DUPLICATE KEY UPDATE parents_id=VALUES(parents_id)';
|
||||||
$database->exec($sql);
|
$database->exec($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
* @property int|string $minHeight Min height for uploaded images, smaller will be refused (default='')
|
* @property int|string $minHeight Min height for uploaded images, smaller will be refused (default='')
|
||||||
* @property string $itemClass Space separated CSS classes for items rendered by this Inputfield. Generally you should append rather than replace.
|
* @property string $itemClass Space separated CSS classes for items rendered by this Inputfield. Generally you should append rather than replace.
|
||||||
* @property int|bool $useImageEditor Whether or not the modal image editor is allowed for this field (default=true)
|
* @property int|bool $useImageEditor Whether or not the modal image editor is allowed for this field (default=true)
|
||||||
|
* @property int $adminThumbScale for backwards compatibility only
|
||||||
*
|
*
|
||||||
* The following properties default values are pulled from $config->adminThumbOptions and can be overridden
|
* The following properties default values are pulled from $config->adminThumbOptions and can be overridden
|
||||||
* by setting directly to an instance of this Inputfield:
|
* by setting directly to an instance of this Inputfield:
|
||||||
@@ -969,6 +970,7 @@ class InputfieldImage extends InputfieldFile implements InputfieldItemList {
|
|||||||
* Return whether or not admin thumbs should be scaled
|
* Return whether or not admin thumbs should be scaled
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
|
* @deprecated
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected function getAdminThumbScale() {
|
protected function getAdminThumbScale() {
|
||||||
|
@@ -245,6 +245,7 @@ class PageRender extends WireData implements Module, ConfigurableModule {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function ___clearCacheFilePages(PageArray $items, Page $page) {
|
public function ___clearCacheFilePages(PageArray $items, Page $page) {
|
||||||
|
if($page) {}
|
||||||
foreach($items as $p) {
|
foreach($items as $p) {
|
||||||
if(((int) $p->template->cache_time) < 1) continue;
|
if(((int) $p->template->cache_time) < 1) continue;
|
||||||
$cf = $this->getCacheFile($p);
|
$cf = $this->getCacheFile($p);
|
||||||
@@ -306,7 +307,6 @@ class PageRender extends WireData implements Module, ConfigurableModule {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$items = array();
|
|
||||||
if(count($pageIDs)) {
|
if(count($pageIDs)) {
|
||||||
$items = $this->wire('pages')->getById($pageIDs, array(
|
$items = $this->wire('pages')->getById($pageIDs, array(
|
||||||
'cache' => false,
|
'cache' => false,
|
||||||
@@ -343,7 +343,9 @@ class PageRender extends WireData implements Module, ConfigurableModule {
|
|||||||
if(!is_string($file)) $file = null;
|
if(!is_string($file)) $file = null;
|
||||||
$event->cancelHooks = true;
|
$event->cancelHooks = true;
|
||||||
$event->replace = true;
|
$event->replace = true;
|
||||||
$event->return = $event->object->renderField($fieldName, $file);
|
/** @var Page $page */
|
||||||
|
$page = $event->object;
|
||||||
|
$event->return = $page->renderField($fieldName, $file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -390,6 +392,7 @@ class PageRender extends WireData implements Module, ConfigurableModule {
|
|||||||
$_page = $this->wire('page'); // just in case one page is rendering another, save the previous
|
$_page = $this->wire('page'); // just in case one page is rendering another, save the previous
|
||||||
$config = $this->wire('config');
|
$config = $this->wire('config');
|
||||||
$compiler = null;
|
$compiler = null;
|
||||||
|
$compilerOptions = array();
|
||||||
if($config->templateCompile && $template->compile) {
|
if($config->templateCompile && $template->compile) {
|
||||||
$compilerOptions = array(
|
$compilerOptions = array(
|
||||||
'namespace' => strlen(__NAMESPACE__) > 0,
|
'namespace' => strlen(__NAMESPACE__) > 0,
|
||||||
@@ -664,10 +667,14 @@ class PageRender extends WireData implements Module, ConfigurableModule {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide a disk cache clearing capability within the module's configuration screen
|
* Provide a disk cache clearing capability within the module's configuration screen
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return InputfieldWrapper
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function getModuleConfigInputfields(array $data) {
|
public function getModuleConfigInputfields(array $data) {
|
||||||
|
|
||||||
|
if($data) {}
|
||||||
$path = $this->wire('config')->paths->cache . self::cacheDirName . '/';
|
$path = $this->wire('config')->paths->cache . self::cacheDirName . '/';
|
||||||
$numPages = 0;
|
$numPages = 0;
|
||||||
$numFiles = 0;
|
$numFiles = 0;
|
||||||
|
Reference in New Issue
Block a user