From c7ca99e5c3746918646653bbd6999f56d96c617a Mon Sep 17 00:00:00 2001 From: mm <312587@qq.com> Date: Fri, 28 Mar 2025 17:25:48 +0800 Subject: [PATCH] Fix multiple issues in extension.php --- xExtension-replaceEntryUrl/extension.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/xExtension-replaceEntryUrl/extension.php b/xExtension-replaceEntryUrl/extension.php index f76cb5a..329d1c0 100644 --- a/xExtension-replaceEntryUrl/extension.php +++ b/xExtension-replaceEntryUrl/extension.php @@ -4,12 +4,15 @@ declare(strict_types=1); class replaceEntryUrlExtension extends Minz_Extension { const ALLOWED_LIST = []; + /** + * @throws FreshRSS_Context_Exception + */ public function init() { if (!FreshRSS_Context::hasSystemConf()) { throw new FreshRSS_Context_Exception('System configuration not initialised!'); } $save = false; - /*If you want to replace it during refresh, uncomment this line and comment out the line below*/ + /*If you want to replace it during refresh, uncomment this line and comment out the line below. it used in test*/ // $this->registerHook('entry_before_display', [self::class, 'processEntry']); $this->registerHook('entry_before_insert', [self::class, 'processEntry']); if (FreshRSS_Context::userConf()->attributeString('allow_url') == null) { @@ -18,6 +21,10 @@ class replaceEntryUrlExtension extends Minz_Extension { } } + + /** + * @throws FreshRSS_Context_Exception + */ public function handleConfigureAction(): void { $this->registerTranslates(); @@ -27,8 +34,17 @@ class replaceEntryUrlExtension extends Minz_Extension { } } + /** + * Process the feed content before inserting the feed + * + * @param FreshRSS_Entry $entry RSS article + * @return FreshRSS_Entry Processed entries + * @throws FreshRSS_Context_Exception + */ public static function processEntry(FreshRSS_Entry $entry): FreshRSS_Entry { - if(FreshRSS_Context::userConf()->attributeString('allow_url')){ + $allow_array = ""; + $allow_url_str = FreshRSS_Context::userConf()->attributeString('allow_url'); + if ($allow_url_str !== null && $allow_url_str !== ''){ $allow_array = json_decode(FreshRSS_Context::userConf()->attributeString('allow_url'),true); } $allow_url = [];