From d433d2033d93d09b1e814cb4e974ec185793e67c Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Wed, 16 Aug 2023 18:20:28 +0200 Subject: [PATCH] remove unused nullsafe check --- _define.php | 2 +- cron-script.php | 2 +- src/Backend.php | 5 +---- src/BackendBehaviors.php | 11 +---------- src/Manage.php | 5 ----- src/ManageFeed.php | 6 +----- src/Template.php | 3 ++- src/ZoneclearFeedServer.php | 6 +----- 8 files changed, 8 insertions(+), 32 deletions(-) diff --git a/_define.php b/_define.php index 0aa3c9f..2dbcdca 100644 --- a/_define.php +++ b/_define.php @@ -10,7 +10,7 @@ * @copyright Jean-Christian Denis * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html */ -if (!defined('DC_RC_PATH') || is_null(dcCore::app()->auth)) { +if (!defined('DC_RC_PATH')) { return null; } diff --git a/cron-script.php b/cron-script.php index 62f69f9..6b76958 100644 --- a/cron-script.php +++ b/cron-script.php @@ -75,7 +75,7 @@ if (is_null(dcCore::app()->blog) || dcCore::app()->blog->id == null) { exit(1); } -if (!isset($opts['u']) || is_null(dcCore::app()->auth) || !dcCore::app()->auth->checkUser(is_string($opts['u']) ? $opts['u'] : '')) { +if (!isset($opts['u']) || !dcCore::app()->auth->checkUser(is_string($opts['u']) ? $opts['u'] : '')) { fwrite(STDERR, "Unable to set user\n"); exit(1); } diff --git a/src/Backend.php b/src/Backend.php index a468d05..2bffedd 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -55,10 +55,7 @@ class Backend extends dcNsProcess ]); // nullsafe - if (is_null(dcCore::app()->auth) - || is_null(dcCore::app()->blog) - || is_null(dcCore::app()->adminurl) - ) { + if (is_null(dcCore::app()->blog)) { return false; } diff --git a/src/BackendBehaviors.php b/src/BackendBehaviors.php index f8dd80e..b7951a9 100644 --- a/src/BackendBehaviors.php +++ b/src/BackendBehaviors.php @@ -233,11 +233,6 @@ class BackendBehaviors */ public static function adminDashboardFavoritesV2(dcFavorites $favs): void { - // nullsafe - if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->adminurl)) { - return; - } - $favs->register(My::id(), [ 'title' => My::name(), 'url' => dcCore::app()->adminurl->get('admin.plugin.' . My::id()), @@ -249,10 +244,6 @@ class BackendBehaviors ]), // update user dashboard favorites icon with nb of updated feeds 'dashboard_cb' => function (ArrayObject $fav): void { - if (is_null(dcCore::app()->adminurl)) { - return; - } - $count = ZoneclearFeedServer::instance()->getFeeds(['feed_status' => '0'], true)->f(0); if (!$count || !is_numeric($count)) { return; @@ -359,7 +350,7 @@ class BackendBehaviors public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, ?MetaRecord $post): void { // nullsafe - if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) { + if (is_null(dcCore::app()->blog)) { return; } diff --git a/src/Manage.php b/src/Manage.php index a54befb..ed85e84 100644 --- a/src/Manage.php +++ b/src/Manage.php @@ -39,7 +39,6 @@ class Manage extends dcNsProcess public static function init(): bool { static::$init == defined('DC_CONTEXT_ADMIN') - && !is_null(dcCore::app()->auth) && !is_null(dcCore::app()->blog) && dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([ dcCore::app()->auth::PERMISSION_CONTENT_ADMIN, @@ -83,10 +82,6 @@ class Manage extends dcNsProcess return; } - if (is_null(dcCore::app()->adminurl)) { - return; - } - $z = ZoneclearFeedServer::instance(); $s = $z->settings; diff --git a/src/ManageFeed.php b/src/ManageFeed.php index 2a4f7ff..c3c2db5 100644 --- a/src/ManageFeed.php +++ b/src/ManageFeed.php @@ -42,7 +42,7 @@ class ManageFeed extends dcNsProcess public static function init(): bool { static::$init == defined('DC_CONTEXT_ADMIN') - && !is_null(dcCore::app()->auth) && !is_null(dcCore::app()->blog) + && !is_null(dcCore::app()->blog) && dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([ dcCore::app()->auth::PERMISSION_CONTENT_ADMIN, ]), dcCore::app()->blog->id) @@ -129,10 +129,6 @@ class ManageFeed extends dcNsProcess return; } - if (is_null(dcCore::app()->adminurl)) { - return; - } - $z = ZoneclearFeedServer::instance(); $s = $z->settings; $v = ManageFeedVars::instance(); diff --git a/src/Template.php b/src/Template.php index bf7ba01..0988c10 100644 --- a/src/Template.php +++ b/src/Template.php @@ -18,6 +18,7 @@ use ArrayObject; use dcCore; use dcTemplate; use Dotclear\Helper\Html\Html; +use Dotclear\Helper\L10n; /** * Frontend template blocks and values. @@ -206,7 +207,7 @@ class Template { return empty($a['full']) ? self::getValue($a, 'dcCore::app()->ctx->feeds->feed_lang') : - 'ctx->feeds->feed_lang])) { ?>' . + 'ctx->feeds->feed_lang])) { ?>' . self::getValue($a, '$langs[dcCore::app()->ctx->feeds->feed_lang]') . '' . self::getValue($a, 'dcCore::app()->ctx->feeds->feed_lang') . diff --git a/src/ZoneclearFeedServer.php b/src/ZoneclearFeedServer.php index 6d1269c..209c902 100644 --- a/src/ZoneclearFeedServer.php +++ b/src/ZoneclearFeedServer.php @@ -471,7 +471,7 @@ class ZoneclearFeedServer $s = $this->settings; # Not configured - if (is_null(dcCore::app()->auth) || !$s->active || !$s->user) { + if (!$s->active || !$s->user) { return false; } @@ -753,10 +753,6 @@ class ZoneclearFeedServer */ public function enableUser(bool $enable = false): void { - if (is_null(dcCore::app()->auth)) { - return; - } - # Enable if ($enable) { // backup current user