fix nullsafe warnings

This commit is contained in:
Jean-Christian Paul Denis 2023-04-23 21:33:37 +02:00
parent efe8358c78
commit 9a2848128f
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
4 changed files with 13 additions and 3 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')) { if (!defined('DC_RC_PATH') || is_null(dcCore::app()->auth)) {
return; return;
} }
@ -22,7 +22,7 @@ $this->registerModule(
[ [
'requires' => [['core', '2.26']], 'requires' => [['core', '2.26']],
'permissions' => dcCore::app()->auth->makePermissions([ 'permissions' => dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_ADMIN, dcCore::app()->auth::PERMISSION_ADMIN,
]), ]),
'type' => 'plugin', 'type' => 'plugin',
'support' => 'https://github.com/JcDenis/' . basename(__DIR__), 'support' => 'https://github.com/JcDenis/' . basename(__DIR__),

View File

@ -43,6 +43,11 @@ class Backend extends dcNsProcess
dcCore::app()->addBehaviors([ dcCore::app()->addBehaviors([
'adminBlogPreferencesFormV2' => function (dcSettings $blog_settings): void { 'adminBlogPreferencesFormV2' => function (dcSettings $blog_settings): void {
// nullsafe
if (is_null(dcCore::app()->blog)) {
return;
}
$exists = []; $exists = [];
$path = Path::fullFromRoot((string) $blog_settings->get('system')->get('public_path'), DC_ROOT); $path = Path::fullFromRoot((string) $blog_settings->get('system')->get('public_path'), DC_ROOT);
foreach (['ico', 'png', 'bmp', 'gif', 'jpg', 'mng'] as $ext) { foreach (['ico', 'png', 'bmp', 'gif', 'jpg', 'mng'] as $ext) {

View File

@ -34,7 +34,7 @@ class Frontend extends dcNsProcess
} }
dcCore::app()->addBehavior('publicHeadContent', function (): void { dcCore::app()->addBehavior('publicHeadContent', function (): void {
if (!dcCore::app()->blog->settings->get('system')->get('simply_favicon')) { if (is_null(dcCore::app()->blog) || !dcCore::app()->blog->settings->get('system')->get('simply_favicon')) {
return; return;
} }

View File

@ -31,6 +31,11 @@ class UrlHandler extends dcUrlHandlers
public static function simplyFaviconUrl(string $arg): void public static function simplyFaviconUrl(string $arg): void
{ {
// nullsafe
if (is_null(dcCore::app()->blog)) {
return;
}
$public_path = Path::fullFromRoot(dcCore::app()->blog->settings->get('system')->get('public_path'), DC_ROOT); $public_path = Path::fullFromRoot(dcCore::app()->blog->settings->get('system')->get('public_path'), DC_ROOT);
if (dcCore::app()->blog->settings->get('system')->get('simply_favicon') if (dcCore::app()->blog->settings->get('system')->get('simply_favicon')