mirror of
https://github.com/typecho/typecho.git
synced 2025-01-17 20:48:42 +01:00
fix #1152
This commit is contained in:
parent
5303124431
commit
ee00fc567f
@ -21,25 +21,30 @@ if (!defined('__TYPECHO_ROOT_DIR__')) {
|
||||
*/
|
||||
abstract class Base extends Widget
|
||||
{
|
||||
/**
|
||||
* init db
|
||||
*/
|
||||
protected const INIT_DB = 0b0001;
|
||||
|
||||
/**
|
||||
* init user widget
|
||||
*/
|
||||
protected const INIT_USER = 0b001;
|
||||
protected const INIT_USER = 0b0010;
|
||||
|
||||
/**
|
||||
* init security widget
|
||||
*/
|
||||
protected const INIT_SECURITY = 0b010;
|
||||
protected const INIT_SECURITY = 0b0100;
|
||||
|
||||
/**
|
||||
* init options widget
|
||||
*/
|
||||
protected const INIT_OPTIONS = 0b100;
|
||||
protected const INIT_OPTIONS = 0b1000;
|
||||
|
||||
/**
|
||||
* init all widgets
|
||||
*/
|
||||
protected const INIT_ALL = 0b111;
|
||||
protected const INIT_ALL = 0b1111;
|
||||
|
||||
/**
|
||||
* init none widget
|
||||
@ -79,11 +84,14 @@ abstract class Base extends Widget
|
||||
*/
|
||||
protected function init()
|
||||
{
|
||||
$this->db = Db::get();
|
||||
$components = self::INIT_ALL;
|
||||
|
||||
$this->initComponents($components);
|
||||
|
||||
if ($components != self::INIT_NONE) {
|
||||
$this->db = Db::get();
|
||||
}
|
||||
|
||||
if ($components & self::INIT_USER) {
|
||||
$this->user = User::alloc();
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ namespace Widget;
|
||||
|
||||
use Typecho\Common;
|
||||
use Typecho\Config;
|
||||
use Typecho\Db;
|
||||
use Typecho\Router;
|
||||
use Typecho\Router\Parser;
|
||||
use Typecho\Widget;
|
||||
@ -111,11 +112,6 @@ class Options extends Base
|
||||
*/
|
||||
private $personalPluginConfig = [];
|
||||
|
||||
/**
|
||||
* @var bool options loaded
|
||||
*/
|
||||
private $loaded = false;
|
||||
|
||||
/**
|
||||
* @param int $components
|
||||
*/
|
||||
@ -131,7 +127,8 @@ class Options extends Base
|
||||
{
|
||||
if (!$parameter->isEmpty()) {
|
||||
$this->row = $this->parameter->toArray();
|
||||
$this->loaded = true;
|
||||
} else {
|
||||
$this->db = Db::get();
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,7 +139,7 @@ class Options extends Base
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
if (!$this->loaded) {
|
||||
if (isset($this->db)) {
|
||||
$values = $this->db->fetchAll($this->db->select()->from('table.options')
|
||||
->where('user = 0'), [$this, 'push']);
|
||||
|
||||
@ -195,7 +192,7 @@ class Options extends Base
|
||||
|
||||
/** 自动初始化路由表 */
|
||||
$this->routingTable = unserialize($this->routingTable);
|
||||
if ($this->loaded && !isset($this->routingTable[0])) {
|
||||
if (isset($this->db) && !isset($this->routingTable[0])) {
|
||||
/** 解析路由并缓存 */
|
||||
$parser = new Parser($this->routingTable);
|
||||
$parsedRoutingTable = $parser->parse();
|
||||
|
Loading…
x
Reference in New Issue
Block a user