From 7edd3f9659612d55759ef6cd939bbd46c99bd39b Mon Sep 17 00:00:00 2001 From: joyqi Date: Fri, 29 Dec 2023 12:59:33 +0800 Subject: [PATCH] fix query --- var/Widget/Archive.php | 14 +++++++------- var/Widget/Contents/From.php | 13 +++++++++++++ var/Widget/Metas/From.php | 13 +++++++++++++ 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/var/Widget/Archive.php b/var/Widget/Archive.php index 988ec8b2..1b83eb21 100644 --- a/var/Widget/Archive.php +++ b/var/Widget/Archive.php @@ -562,12 +562,12 @@ class Archive extends Contents /** 定时发布功能 */ if (!$selectPlugged) { - if ($this->parameter->preview) { - $select = $this->select(); - } else { + $select = $this->select('table.contents.*'); + + if (!$this->parameter->preview) { if ('post' == $this->parameter->type || 'page' == $this->parameter->type) { if ($this->user->hasLogin()) { - $select = $this->select()->where( + $select->where( 'table.contents.status = ? OR table.contents.status = ? OR (table.contents.status = ? AND table.contents.authorId = ?)', 'publish', @@ -576,7 +576,7 @@ class Archive extends Contents $this->user->uid ); } else { - $select = $this->select()->where( + $select->where( 'table.contents.status = ? OR table.contents.status = ?', 'publish', 'hidden' @@ -584,14 +584,14 @@ class Archive extends Contents } } else { if ($this->user->hasLogin()) { - $select = $this->select()->where( + $select->where( 'table.contents.status = ? OR (table.contents.status = ? AND table.contents.authorId = ?)', 'publish', 'private', $this->user->uid ); } else { - $select = $this->select()->where('table.contents.status = ?', 'publish'); + $select->where('table.contents.status = ?', 'publish'); } } $select->where('table.contents.created < ?', $this->options->time); diff --git a/var/Widget/Contents/From.php b/var/Widget/Contents/From.php index 9d223848..fdb7198f 100644 --- a/var/Widget/Contents/From.php +++ b/var/Widget/Contents/From.php @@ -2,6 +2,7 @@ namespace Widget\Contents; +use Typecho\Config; use Typecho\Db\Exception; use Widget\Base\Contents; use Widget\Base\TreeTrait; @@ -20,6 +21,18 @@ class From extends Contents ___directory as ___treeDirectory; } + /** + * @param Config $parameter + * @return void + */ + protected function initParameter(Config $parameter) + { + $parameter->setDefault([ + 'cid' => null, + 'query' => null, + ]); + } + /** * @return void * @throws Exception diff --git a/var/Widget/Metas/From.php b/var/Widget/Metas/From.php index 0566203a..0a36382e 100644 --- a/var/Widget/Metas/From.php +++ b/var/Widget/Metas/From.php @@ -2,6 +2,7 @@ namespace Widget\Metas; +use Typecho\Config; use Typecho\Db\Exception; use Widget\Base\Metas; use Widget\Base\TreeTrait; @@ -14,6 +15,18 @@ class From extends Metas initParameter as initTreeParameter; } + /** + * @param Config $parameter + * @return void + */ + protected function initParameter(Config $parameter) + { + $parameter->setDefault([ + 'mid' => null, + 'query' => null, + ]); + } + /** * @return void * @throws Exception