cosmetic nullsafe fix

This commit is contained in:
Jean-Christian Paul Denis 2023-04-20 21:29:42 +02:00
parent 42fcd1d204
commit 52f3e80180
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
3 changed files with 21 additions and 1 deletions

View File

@ -21,7 +21,9 @@ class Backend extends dcNsProcess
{
public static function init(): bool
{
static::$init = defined('DC_CONTEXT_ADMIN') && dcCore::app()->auth->isSuperAdmin();
static::$init = defined('DC_CONTEXT_ADMIN')
&& !is_null(dcCore::app()->auth) // nullsafe PHP < 8.0
&& dcCore::app()->auth->isSuperAdmin();
return static::$init;
}

View File

@ -26,18 +26,33 @@ class BackendBehaviors
# admin plugins page tab
public static function pluginsTabs(): void
{
// nullsafe PHP < 8.0
if (is_null(dcCore::app()->adminurl)) {
return;
}
self::modulesToolsTabs(dcCore::app()->plugins, explode(',', DC_DISTRIB_PLUGINS), dcCore::app()->adminurl->get('admin.plugins'));
}
# admin themes page tab
public static function themesTabs(): void
{
// nullsafe PHP < 8.0
if (is_null(dcCore::app()->adminurl)) {
return;
}
self::modulesToolsTabs(dcCore::app()->themes, explode(',', DC_DISTRIB_THEMES), dcCore::app()->adminurl->get('admin.blog.theme'));
}
# generic page tab
private static function modulesToolsTabs(dcModules $modules, array $excludes, string $page_url): void
{
// nullsafe PHP < 8.0
if (is_null(dcCore::app()->blog)) {
return;
}
$repos = empty($_POST['csvcheck']) ? null :
(new CsvStore($modules, (string) dcCore::app()->blog->settings->get('system')->get('store_plugin_url'), true))->get(true);

View File

@ -27,6 +27,9 @@ class CsvStoreParser extends dcStoreParser
foreach ($this->xml->module as $i) {
$attrs = $i->attributes();
if (!isset($attrs['id'])) {
continue;
}
$item = [];