From 157fc05265ad05008198498d4f8cd89189414db8 Mon Sep 17 00:00:00 2001 From: joyqi Date: Mon, 13 Dec 2021 11:58:35 +0800 Subject: [PATCH] fix #1268 --- .github/workflows/Typecho-dev-Ci.yml | 2 +- var/Typecho/Common.php | 4 +++- var/Typecho/Db/Adapter/QueryTrait.php | 6 +++--- var/Widget/Base/Contents.php | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/Typecho-dev-Ci.yml b/.github/workflows/Typecho-dev-Ci.yml index d692fea3..9469ba3e 100644 --- a/.github/workflows/Typecho-dev-Ci.yml +++ b/.github/workflows/Typecho-dev-Ci.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.2', '7.3', '7.4', '8.0'] + php: ['7.2', '7.3', '7.4', '8.0', '8.1'] steps: - name: Checkout code uses: actions/checkout@v2 diff --git a/var/Typecho/Common.php b/var/Typecho/Common.php index 45c930ce..2755f42e 100644 --- a/var/Typecho/Common.php +++ b/var/Typecho/Common.php @@ -182,8 +182,10 @@ namespace Typecho { */ public static function url(?string $path, ?string $prefix): string { + $path = $path ?? ''; $path = (0 === strpos($path, './')) ? substr($path, 2) : $path; - return rtrim($prefix, '/') . '/' . str_replace('//', '/', ltrim($path, '/')); + return rtrim($prefix ?? '', '/') . '/' + . str_replace('//', '/', ltrim($path, '/')); } /** diff --git a/var/Typecho/Db/Adapter/QueryTrait.php b/var/Typecho/Db/Adapter/QueryTrait.php index aa2e0c13..45f1d914 100644 --- a/var/Typecho/Db/Adapter/QueryTrait.php +++ b/var/Typecho/Db/Adapter/QueryTrait.php @@ -20,10 +20,10 @@ trait QueryTrait } } - $sql['limit'] = (0 == strlen($sql['limit'])) ? null : ' LIMIT ' . $sql['limit']; - $sql['offset'] = (0 == strlen($sql['offset'])) ? null : ' OFFSET ' . $sql['offset']; + $sql['limit'] = isset($sql['limit']) ? ' LIMIT ' . $sql['limit'] : ''; + $sql['offset'] = isset($sql['offset']) ? ' OFFSET ' . $sql['offset'] : ''; return 'SELECT ' . $sql['fields'] . ' FROM ' . $sql['table'] . $sql['where'] . $sql['group'] . $sql['having'] . $sql['order'] . $sql['limit'] . $sql['offset']; } -} \ No newline at end of file +} diff --git a/var/Widget/Base/Contents.php b/var/Widget/Base/Contents.php index 8a49ebe7..4df1d98d 100644 --- a/var/Widget/Base/Contents.php +++ b/var/Widget/Base/Contents.php @@ -585,7 +585,7 @@ class Contents extends Base implements QueryInterface /** 处理密码保护流程 */ if ( - strlen($value['password']) > 0 && + strlen($value['password'] ?? '') > 0 && $value['password'] !== Cookie::get('protectPassword_' . $value['cid']) && $value['authorId'] != $this->user->uid && !$this->user->pass('editor', true)