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) {
|
||||
if(!is_object($tpl)) $tpl = $this->wire('templates')->get($tpl);
|
||||
if(!$tpl instanceof Template) throw new WireException("Invalid value sent to Page::setTemplate");
|
||||
if($this->template && $this->template->id != $tpl->id) {
|
||||
if($this->settings['status'] & Page::statusSystem) throw new WireException("Template changes are disallowed on this page");
|
||||
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(is_null($this->templatePrevious)) $this->templatePrevious = $this->template;
|
||||
$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)) {
|
||||
throw new WireException("Page cannot be its own parent");
|
||||
}
|
||||
if($this->isLoaded) {
|
||||
$this->trackChange('parent', $this->parent, $parent);
|
||||
if(($this->parent && $this->parent->id) && $this->parent->id != $parent->id) {
|
||||
if($this->settings['status'] & Page::statusSystem) throw new WireException("Parent changes are disallowed on this page");
|
||||
$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;
|
||||
return $this;
|
||||
|
@@ -879,7 +879,10 @@ class PagesEditor extends Wire {
|
||||
} while(1);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@@ -16,6 +16,7 @@
|
||||
* @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 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
|
||||
* 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 bool
|
||||
* @deprecated
|
||||
*
|
||||
*/
|
||||
protected function getAdminThumbScale() {
|
||||
|
@@ -245,6 +245,7 @@ class PageRender extends WireData implements Module, ConfigurableModule {
|
||||
*
|
||||
*/
|
||||
public function ___clearCacheFilePages(PageArray $items, Page $page) {
|
||||
if($page) {}
|
||||
foreach($items as $p) {
|
||||
if(((int) $p->template->cache_time) < 1) continue;
|
||||
$cf = $this->getCacheFile($p);
|
||||
@@ -306,7 +307,6 @@ class PageRender extends WireData implements Module, ConfigurableModule {
|
||||
));
|
||||
}
|
||||
|
||||
$items = array();
|
||||
if(count($pageIDs)) {
|
||||
$items = $this->wire('pages')->getById($pageIDs, array(
|
||||
'cache' => false,
|
||||
@@ -343,7 +343,9 @@ class PageRender extends WireData implements Module, ConfigurableModule {
|
||||
if(!is_string($file)) $file = null;
|
||||
$event->cancelHooks = 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
|
||||
$config = $this->wire('config');
|
||||
$compiler = null;
|
||||
$compilerOptions = array();
|
||||
if($config->templateCompile && $template->compile) {
|
||||
$compilerOptions = array(
|
||||
'namespace' => strlen(__NAMESPACE__) > 0,
|
||||
@@ -665,9 +668,13 @@ class PageRender extends WireData implements Module, ConfigurableModule {
|
||||
/**
|
||||
* Provide a disk cache clearing capability within the module's configuration screen
|
||||
*
|
||||
* @param array $data
|
||||
* @return InputfieldWrapper
|
||||
*
|
||||
*/
|
||||
public function getModuleConfigInputfields(array $data) {
|
||||
|
||||
if($data) {}
|
||||
$path = $this->wire('config')->paths->cache . self::cacheDirName . '/';
|
||||
$numPages = 0;
|
||||
$numFiles = 0;
|
||||
|
Reference in New Issue
Block a user