remove unused nullsafe check

This commit is contained in:
Jean-Christian 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 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;
}

View file

@ -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);
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;

View file

@ -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();

View file

@ -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') :
'<?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]') .
'<?php } else { ?>' .
self::getValue($a, 'dcCore::app()->ctx->feeds->feed_lang') .

View file

@ -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