Skip to content

Commit

Permalink
Merge branch 'master' of github.com:typecho/typecho
Browse files Browse the repository at this point in the history
  • Loading branch information
joyqi committed Oct 21, 2021
2 parents cb4457a + 8a57b91 commit 6b46dd9
Show file tree
Hide file tree
Showing 16 changed files with 137 additions and 59 deletions.
11 changes: 9 additions & 2 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ function install_get_lang(): string
*/
function install_get_site_url(): string
{
return install_is_cli() ? 'http://localhost' : \Typecho\Request::getInstance()->getRequestRoot();
$request = \Typecho\Request::getInstance();
return install_is_cli() ? $request->getServer('TYPECHO_SITE_URL', 'http://localhost') : $request->getRequestRoot();
}

/**
Expand Down Expand Up @@ -508,7 +509,13 @@ function install_raise_error($error, $config = null)
*/
function install_success($step, ?array $config = null)
{
global $installDb;

if (install_is_cli()) {
if ($step == 3) {
\Typecho\Db::set($installDb);
}

if ($step > 0) {
$method = 'install_step_' . $step . '_perform';
$method();
Expand Down Expand Up @@ -1314,7 +1321,7 @@ function install_step_3_perform()
'cid' => 1, 'created' => \Typecho\Date::time(),
'author' => 'Typecho',
'ownerId' => 1,
'url' => 'http://typecho.org',
'url' => 'https://typecho.org',
'ip' => '127.0.0.1',
'agent' => $options->generator,
'text' => '欢迎加入 Typecho 大家族',
Expand Down
3 changes: 1 addition & 2 deletions var/IXR/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public function __construct(array $callbacks = [])
$this->setCapabilities();
$this->callbacks = $callbacks;
$this->setCallbacks();
$this->serve();
}

/**
Expand Down Expand Up @@ -298,7 +297,7 @@ private function setCallbacks()
/**
* 服务入口
*/
private function serve()
public function serve()
{
$message = new Message(file_get_contents('php://input') ?: '');

Expand Down
8 changes: 8 additions & 0 deletions var/Typecho/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ public function __construct($adapterName, string $prefix = 'typecho_')
$this->adapter = new $adapterName();
}

/**
* @return Adapter
*/
public function getAdapter(): Adapter
{
return $this->adapter;
}

/**
* 获取适配器名称
*
Expand Down
7 changes: 7 additions & 0 deletions var/Typecho/Db/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ public function connect(Config $config);
*/
public function getVersion($handle): string;

/**
* 获取数据库类型
*
* @return string
*/
public function getDriver(): string;

/**
* 清空数据表
*
Expand Down
8 changes: 8 additions & 0 deletions var/Typecho/Db/Adapter/MysqlTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,12 @@ public function parseSelect(array $sql): string
{
return $this->buildQuery($sql);
}

/**
* @return string
*/
public function getDriver(): string
{
return 'mysql';
}
}
2 changes: 1 addition & 1 deletion var/Typecho/Db/Adapter/Mysqli.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function connect(Config $config): \mysqli
*/
public function getVersion($handle): string
{
return 'mysqli:mysql ' . $this->dbLink->server_version;
return $this->dbLink->server_version;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions var/Typecho/Db/Adapter/Pdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ abstract public function init(Config $config): \PDO;
*/
public function getVersion($handle): string
{
return 'pdo:' . $handle->getAttribute(\PDO::ATTR_DRIVER_NAME)
. ' ' . $handle->getAttribute(\PDO::ATTR_SERVER_VERSION);
return $handle->getAttribute(\PDO::ATTR_SERVER_VERSION);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion var/Typecho/Db/Adapter/Pgsql.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function connect(Config $config)
public function getVersion($handle): string
{
$version = pg_version($handle);
return 'pgsql:pgsql ' . $version['server'];
return $version['server'];
}

/**
Expand Down
8 changes: 8 additions & 0 deletions var/Typecho/Db/Adapter/PgsqlTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ public function lastInsertId($resource, $handle): int
return 0;
}

/**
* @return string
*/
public function getDriver(): string
{
return 'pgsql';
}

abstract public function query(
string $query,
$handle,
Expand Down
2 changes: 1 addition & 1 deletion var/Typecho/Db/Adapter/SQLite.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function connect(Config $config): \SQLite3
*/
public function getVersion($handle): string
{
return 'sqlite:sqlite ' . \SQLite3::version()['versionString'];
return \SQLite3::version()['versionString'];
}

/**
Expand Down
8 changes: 8 additions & 0 deletions var/Typecho/Db/Adapter/SQLiteTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,12 @@ public function parseSelect(array $sql): string

return $query;
}

/**
* @return string
*/
public function getDriver(): string
{
return 'sqlite';
}
}
1 change: 0 additions & 1 deletion var/Typecho/I18n.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ private static function init()
* @param string $single 单数形式的翻译
* @param string $plural 复数形式的翻译
* @param integer $number 数字
*
* @return string
*/
public static function ngettext(string $single, string $plural, int $number): string
Expand Down
4 changes: 2 additions & 2 deletions var/Typecho/I18n/GetText.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function ngettext($single, $plural, $number, ?int &$num): string
} else {
$result = $this->cache_translations[$key];
$list = explode(chr(0), $result);
return $list[$select];
return $list[$select] ?? '';
}
} else {
$num = $this->findString($key);
Expand All @@ -176,7 +176,7 @@ public function ngettext($single, $plural, $number, ?int &$num): string
} else {
$result = $this->getTranslationString($num);
$list = explode(chr(0), $result);
return $list[$select];
return $list[$select] ?? '';
}
}
}
Expand Down
Loading

0 comments on commit 6b46dd9

Please sign in to comment.