cosmetic nullsafe fix
This commit is contained in:
parent
fc0a146a12
commit
cd5f71d98c
4 changed files with 42 additions and 2 deletions
|
@ -26,6 +26,7 @@ class Backend extends dcNsProcess
|
|||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||
&& My::phpCompliant()
|
||||
&& !is_null(dcCore::app()->auth) && !is_null(dcCore::app()->blog) // nullsafe PHP < 8.0
|
||||
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||
]), dcCore::app()->blog->id);
|
||||
|
@ -39,6 +40,11 @@ class Backend extends dcNsProcess
|
|||
return false;
|
||||
}
|
||||
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
||||
My::name(),
|
||||
dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
|
||||
|
@ -50,11 +56,19 @@ class Backend extends dcNsProcess
|
|||
|
||||
dcCore::app()->addBehaviors([
|
||||
'adminPageHTMLHead' => function (): void {
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return;
|
||||
}
|
||||
if (dcCore::app()->blog->settings->get(My::id())->get('flag')) {
|
||||
echo dcPage::cssModuleLoad(My::id() . '/css/backend.css');
|
||||
}
|
||||
},
|
||||
'adminDashboardFavoritesV2' => function (dcFavorites $favs): void {
|
||||
// nullsafe PHP < 8.0
|
||||
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()),
|
||||
|
|
|
@ -36,6 +36,11 @@ class Frontend extends dcNsProcess
|
|||
}
|
||||
|
||||
dcCore::app()->addBehavior('publicBeforeDocument', function (): void {
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!dcCore::app()->blog->settings->get(My::id())->get('flag')) {
|
||||
return;
|
||||
}
|
||||
|
@ -53,12 +58,17 @@ class Frontend extends dcNsProcess
|
|||
}
|
||||
$extra_urls = json_decode(dcCore::app()->blog->settings->get(My::id())->get('extra_urls'), true);
|
||||
if (!in_array(Http::realIP(), $all_allowed_ip)) {
|
||||
dcCore::app()->url->registerDefault(function ($args) {
|
||||
dcCore::app()->url->registerDefault(function (?string $args): void {
|
||||
dcCore::app()->url->type = 'default';
|
||||
|
||||
throw new Exception('Blog under construction', 503);
|
||||
});
|
||||
dcCore::app()->url->registerError(function ($args, $type, $e) {
|
||||
dcCore::app()->url->registerError(function (?string $args, ?string $type, Exception $e): void {
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->ctx)) {
|
||||
return;
|
||||
}
|
||||
|
||||
header('Content-Type: text/html; charset=UTF-8');
|
||||
Http::head(503, 'Service Unavailable');
|
||||
dcCore::app()->url->type = '503';
|
||||
|
|
|
@ -35,6 +35,11 @@ class Install extends dcNsProcess
|
|||
return false;
|
||||
}
|
||||
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$s = dcCore::app()->blog->settings->get(My::id());
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ class Manage extends dcNsProcess
|
|||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||
&& My::phpCompliant()
|
||||
&& !is_null(dcCore::app()->auth) && !is_null(dcCore::app()->blog) // nullsafe PHP < 8.0
|
||||
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||
]), dcCore::app()->blog->id);
|
||||
|
@ -54,6 +55,11 @@ class Manage extends dcNsProcess
|
|||
return false;
|
||||
}
|
||||
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$s = dcCore::app()->blog->settings->get(My::id());
|
||||
|
||||
if (!empty($_POST['saveconfig'])) {
|
||||
|
@ -96,6 +102,11 @@ class Manage extends dcNsProcess
|
|||
return;
|
||||
}
|
||||
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$s = dcCore::app()->blog->settings->get(My::id());
|
||||
$editor = dcCore::app()->auth->getOption('editor');
|
||||
$nb_rows = count(json_decode($s->get('allowed_ip'), true));
|
||||
|
|
Loading…
Reference in a new issue