mirror of
https://github.com/typecho/typecho.git
synced 2025-03-20 01:49:40 +01:00
Merge branch 'dev' of github.com:typecho/typecho into dev
This commit is contained in:
commit
31ed159312
7
.github/workflows/Typecho-dev-Ci.yml
vendored
7
.github/workflows/Typecho-dev-Ci.yml
vendored
@ -47,5 +47,8 @@ jobs:
|
||||
- name: Upload a Build Artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: typecho
|
||||
path: ./build/
|
||||
name: typecho
|
||||
path: ./build/
|
||||
- name: Trigger build
|
||||
run: |
|
||||
curl -XPOST -u "${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" https://api.github.com/repos/typecho/languages/actions/workflows/update.yml/dispatches --data '{"ref": "master"}'
|
||||
|
@ -65,7 +65,7 @@ function _n(string $single, string $plural, int $number): string
|
||||
class Typecho_Common
|
||||
{
|
||||
/** 程序版本 */
|
||||
const VERSION = '1.2/18.10.23';
|
||||
const VERSION = '1.2.0';
|
||||
|
||||
/**
|
||||
* 默认编码
|
||||
|
@ -210,7 +210,7 @@ abstract class Typecho_Widget
|
||||
*
|
||||
* @param boolean $condition 触发条件
|
||||
*
|
||||
* @return mixed
|
||||
* @return $this|Typecho_Widget_Helper_Empty
|
||||
*/
|
||||
public function on(bool $condition)
|
||||
{
|
||||
@ -408,6 +408,22 @@ abstract class Typecho_Widget
|
||||
$this->row[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSequence(): int
|
||||
{
|
||||
return $this->sequence;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLength(): int
|
||||
{
|
||||
return $this->length;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证堆栈值是否存在
|
||||
*
|
||||
|
@ -346,16 +346,16 @@ Typecho_Date::setTimezoneOffset($options->timezone);
|
||||
public static function v0_6r9_4_21($db, $options)
|
||||
{
|
||||
//创建上传目录
|
||||
$uploadDir = Typecho_Common::url(Widget_Upload::UPLOAD_PATH, __TYPECHO_ROOT_DIR__);
|
||||
$uploadDir = Typecho_Common::url(Widget_Upload::UPLOAD_DIR, __TYPECHO_ROOT_DIR__);
|
||||
if (is_dir($uploadDir)) {
|
||||
if (!is_writeable($uploadDir)) {
|
||||
if (!@chmod($uploadDir, 0644)) {
|
||||
throw new Typecho_Widget_Exception(_t('上传目录无法写入, 请手动将安装目录下的 %s 目录的权限设置为可写然后继续升级', Widget_Upload::UPLOAD_PATH));
|
||||
throw new Typecho_Widget_Exception(_t('上传目录无法写入, 请手动将安装目录下的 %s 目录的权限设置为可写然后继续升级', Widget_Upload::UPLOAD_DIR));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!@mkdir($uploadDir, 0644)) {
|
||||
throw new Typecho_Widget_Exception(_t('上传目录无法创建, 请手动创建安装目录下的 %s 目录, 并将它的权限设置为可写然后继续升级', Widget_Upload::UPLOAD_PATH));
|
||||
throw new Typecho_Widget_Exception(_t('上传目录无法创建, 请手动创建安装目录下的 %s 目录, 并将它的权限设置为可写然后继续升级', Widget_Upload::UPLOAD_DIR));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,67 +19,46 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit;
|
||||
*/
|
||||
class Widget_Upgrade extends Widget_Abstract_Options implements Widget_Interface_Do
|
||||
{
|
||||
/**
|
||||
* 当前内部版本号
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_currentVersion;
|
||||
|
||||
/**
|
||||
* 对升级包按版本进行排序
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param string $a a版本
|
||||
* @param string $b b版本
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function sortPackage($a, $b)
|
||||
{
|
||||
[$ver, $rev] = explode('r', $a);
|
||||
$a = str_replace('_', '.', $rev);
|
||||
|
||||
[$ver, $rev] = explode('r', $b);
|
||||
$b = str_replace('_', '.', $rev);
|
||||
|
||||
return version_compare($a, $b, '>') ? 1 : - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤低版本的升级包
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param string $version 版本号
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function filterPackage($version)
|
||||
{
|
||||
[$ver, $rev] = explode('r', $version);
|
||||
$rev = str_replace('_', '.', $rev);
|
||||
return version_compare($rev, $this->_currentVersion, '>');
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行升级程序
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
* @throws Typecho_Exception
|
||||
*/
|
||||
public function upgrade()
|
||||
{
|
||||
[$prefix, $this->_currentVersion] = explode('/', $this->options->generator);
|
||||
$packages = get_class_methods('Upgrade');
|
||||
$packages = array_filter($packages, [$this, 'filterPackage']);
|
||||
usort($packages, [$this, 'sortPackage']);
|
||||
|
||||
preg_match("/^\w+ ([0-9\.]+)(\/[0-9\.]+)?$/i", $this->options->generator, $matches);
|
||||
$currentVersion = $matches[1];
|
||||
$currentMinor = '0';
|
||||
if (isset($matches[2])) {
|
||||
$currentMinor = substr($matches[2], 1);
|
||||
}
|
||||
|
||||
$message = [];
|
||||
|
||||
foreach ($packages as $package) {
|
||||
preg_match("/^v([_0-9]+)(r[_0-9]+)?$/", $package, $matches);
|
||||
|
||||
$version = str_replace('_', '.', $matches[1]);
|
||||
|
||||
if (version_compare($currentVersion, $version, '>')) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (isset($matches[2])) {
|
||||
$minor = substr(str_replace('_', '.', $matches[2]), 1);
|
||||
|
||||
if (version_compare($currentVersion, $version, '=')
|
||||
&& version_compare($currentMinor, $minor, '>=')) {
|
||||
break;
|
||||
}
|
||||
|
||||
$version .= '/' . $minor;
|
||||
}
|
||||
|
||||
$options = $this->widget('Widget_Options@' . $package);
|
||||
|
||||
/** 执行升级脚本 */
|
||||
@ -94,12 +73,8 @@ class Widget_Upgrade extends Widget_Abstract_Options implements Widget_Interface
|
||||
return;
|
||||
}
|
||||
|
||||
[$ver, $rev] = explode('r', $package);
|
||||
$ver = substr(str_replace('_', '.', $ver), 1);
|
||||
$rev = str_replace('_', '.', $rev);
|
||||
|
||||
/** 更新版本号 */
|
||||
$this->update(['value' => 'Typecho ' . $ver . '/' . $rev],
|
||||
$this->update(['value' => 'Typecho ' . $version],
|
||||
$this->db->sql()->where('name = ?', 'generator'));
|
||||
|
||||
$this->destroy('Widget_Options@' . $package);
|
||||
|
Loading…
x
Reference in New Issue
Block a user