From f34d14280db442e26ff97d52c2949d0872ffe105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn> Date: Tue, 15 Feb 2022 11:10:47 +0800 Subject: [PATCH] Fix compatibility with PHP 8.1 (#1324) * Fix compatibility with PHP 8.1 PHP Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in typecho/var/Widget/Archive.php on line 1292 * Fix login * Fix write * Fix manage * Fix PHP Deprecated --- admin/login.php | 4 ++-- admin/manage-comments.php | 2 +- admin/manage-medias.php | 2 +- admin/manage-pages.php | 2 +- admin/manage-users.php | 2 +- admin/write-page.php | 4 ++-- admin/write-post.php | 8 ++++---- var/Typecho/Response.php | 2 +- var/Widget/Archive.php | 2 +- var/Widget/User.php | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/admin/login.php b/admin/login.php index 3c49bd3629..e51d5789d2 100644 --- a/admin/login.php +++ b/admin/login.php @@ -4,7 +4,7 @@ if ($user->hasLogin()) { $response->redirect($options->adminUrl); } -$rememberName = htmlspecialchars(\Typecho\Cookie::get('__typecho_remember_name')); +$rememberName = htmlspecialchars(\Typecho\Cookie::get('__typecho_remember_name', '')); \Typecho\Cookie::delete('__typecho_remember_name'); $bodyClass = 'body-100'; @@ -25,7 +25,7 @@

- +

@@ -43,7 +43,7 @@ class="edit-draft-notice"> + name="text" class="w-100 mono">text ?? ''); ?>

diff --git a/admin/write-post.php b/admin/write-post.php index 896b4b0057..1f9a40a877 100644 --- a/admin/write-post.php +++ b/admin/write-post.php @@ -38,7 +38,7 @@ class="edit-draft-notice">cid, $post->category, $post->year, $post->month, $post->day ], $permalink); } - $input = ''; + $input = ''; ?>

@@ -47,7 +47,7 @@ class="edit-draft-notice"> + name="text" class="w-100 mono">text ?? ''); ?>

@@ -134,7 +134,7 @@ class="i-caret-down"> + value="password"password ?? '') > 0): ?> selected> @@ -142,7 +142,7 @@ class="i-caret-down"> value="waiting"pass('editor', true) || $post->status == 'waiting'): ?> selected>

-

password) == 0): ?> class="hidden"> +

password ?? '') == 0): ?> class="hidden"> response->redirect(defined('__TYPECHO_ADMIN__') ? $this->options->loginUrl . - (0 === strpos($this->request->getReferer(), $this->options->loginUrl) ? '' : + (0 === strpos($this->request->getReferer() ?? '', $this->options->loginUrl) ? '' : '?referer=' . urlencode($this->request->makeUriByRequest())) : $this->options->siteUrl, false); } }