remove unused nullsafe check

master
Jean-Christian Paul Denis 2023-08-16 18:20:28 +02:00
parent 01db3e79a5
commit d433d2033d
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
8 changed files with 8 additions and 32 deletions

View File

@ -10,7 +10,7 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @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; return null;
} }

View File

@ -75,7 +75,7 @@ if (is_null(dcCore::app()->blog) || dcCore::app()->blog->id == null) {
exit(1); 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"); fwrite(STDERR, "Unable to set user\n");
exit(1); exit(1);
} }

View File

@ -55,10 +55,7 @@ class Backend extends dcNsProcess
]); ]);
// nullsafe // nullsafe
if (is_null(dcCore::app()->auth) if (is_null(dcCore::app()->blog)) {
|| is_null(dcCore::app()->blog)
|| is_null(dcCore::app()->adminurl)
) {
return false; return false;
} }

View File

@ -233,11 +233,6 @@ class BackendBehaviors
*/ */
public static function adminDashboardFavoritesV2(dcFavorites $favs): void public static function adminDashboardFavoritesV2(dcFavorites $favs): void
{ {
// nullsafe
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->adminurl)) {
return;
}
$favs->register(My::id(), [ $favs->register(My::id(), [
'title' => My::name(), 'title' => My::name(),
'url' => dcCore::app()->adminurl->get('admin.plugin.' . My::id()), '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 // update user dashboard favorites icon with nb of updated feeds
'dashboard_cb' => function (ArrayObject $fav): void { 'dashboard_cb' => function (ArrayObject $fav): void {
if (is_null(dcCore::app()->adminurl)) {
return;
}
$count = ZoneclearFeedServer::instance()->getFeeds(['feed_status' => '0'], true)->f(0); $count = ZoneclearFeedServer::instance()->getFeeds(['feed_status' => '0'], true)->f(0);
if (!$count || !is_numeric($count)) { if (!$count || !is_numeric($count)) {
return; return;
@ -359,7 +350,7 @@ class BackendBehaviors
public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, ?MetaRecord $post): void public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, ?MetaRecord $post): void
{ {
// nullsafe // nullsafe
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) { if (is_null(dcCore::app()->blog)) {
return; return;
} }

View File

@ -39,7 +39,6 @@ class Manage extends dcNsProcess
public static function init(): bool public static function init(): bool
{ {
static::$init == defined('DC_CONTEXT_ADMIN') 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->check(dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN, dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
@ -83,10 +82,6 @@ class Manage extends dcNsProcess
return; return;
} }
if (is_null(dcCore::app()->adminurl)) {
return;
}
$z = ZoneclearFeedServer::instance(); $z = ZoneclearFeedServer::instance();
$s = $z->settings; $s = $z->settings;

View File

@ -42,7 +42,7 @@ class ManageFeed extends dcNsProcess
public static function init(): bool public static function init(): bool
{ {
static::$init == defined('DC_CONTEXT_ADMIN') 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->check(dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN, dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
]), dcCore::app()->blog->id) ]), dcCore::app()->blog->id)
@ -129,10 +129,6 @@ class ManageFeed extends dcNsProcess
return; return;
} }
if (is_null(dcCore::app()->adminurl)) {
return;
}
$z = ZoneclearFeedServer::instance(); $z = ZoneclearFeedServer::instance();
$s = $z->settings; $s = $z->settings;
$v = ManageFeedVars::instance(); $v = ManageFeedVars::instance();

View File

@ -18,6 +18,7 @@ use ArrayObject;
use dcCore; use dcCore;
use dcTemplate; use dcTemplate;
use Dotclear\Helper\Html\Html; use Dotclear\Helper\Html\Html;
use Dotclear\Helper\L10n;
/** /**
* Frontend template blocks and values. * Frontend template blocks and values.
@ -206,7 +207,7 @@ class Template
{ {
return empty($a['full']) ? return empty($a['full']) ?
self::getValue($a, 'dcCore::app()->ctx->feeds->feed_lang') : self::getValue($a, 'dcCore::app()->ctx->feeds->feed_lang') :
'<?php $langs = l10n::getISOcodes(); if (isset($langs[dcCore::app()->ctx->feeds->feed_lang])) { ?>' . '<?php $langs = ' . L10n::class . '::getISOcodes(); if (isset($langs[dcCore::app()->ctx->feeds->feed_lang])) { ?>' .
self::getValue($a, '$langs[dcCore::app()->ctx->feeds->feed_lang]') . self::getValue($a, '$langs[dcCore::app()->ctx->feeds->feed_lang]') .
'<?php } else { ?>' . '<?php } else { ?>' .
self::getValue($a, 'dcCore::app()->ctx->feeds->feed_lang') . self::getValue($a, 'dcCore::app()->ctx->feeds->feed_lang') .

View File

@ -471,7 +471,7 @@ class ZoneclearFeedServer
$s = $this->settings; $s = $this->settings;
# Not configured # Not configured
if (is_null(dcCore::app()->auth) || !$s->active || !$s->user) { if (!$s->active || !$s->user) {
return false; return false;
} }
@ -753,10 +753,6 @@ class ZoneclearFeedServer
*/ */
public function enableUser(bool $enable = false): void public function enableUser(bool $enable = false): void
{ {
if (is_null(dcCore::app()->auth)) {
return;
}
# Enable # Enable
if ($enable) { if ($enable) {
// backup current user // backup current user