fix nullsafe warnings

This commit is contained in:
Jean-Christian Paul Denis 2023-04-23 22:07:10 +02:00
parent 42d301a77e
commit 58bee72e62
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
3 changed files with 30 additions and 9 deletions

View File

@ -9,10 +9,12 @@
# DOT NOT MODIFY THIS FILE !
#
l10n::$locales['You must provide a content.'] = 'Vous devez fournir un contenu.';
l10n::$locales['Mail successuffly sent.'] = 'Mail envoyer avec succès.';
l10n::$locales['Mailto:'] = 'Envoyer à :';
l10n::$locales['Subject:'] = 'Sujet :';
l10n::$locales['Active mail headers'] = 'Activer les entêtes de mail';
l10n::$locales['Mail test'] = 'Testeur de mail';
l10n::$locales['Send a simple mail from admin'] = 'Envoyer un simple mail depuis l\'admin';
use Dotclear\Helper\L10n;
L10n::$locales['You must provide a content.'] = 'Vous devez fournir un contenu.';
L10n::$locales['Mail successuffly sent.'] = 'Mail envoyer avec succès.';
L10n::$locales['Mailto:'] = 'Envoyer à :';
L10n::$locales['Subject:'] = 'Sujet :';
L10n::$locales['Active mail headers'] = 'Activer les entêtes de mail';
L10n::$locales['Mail test'] = 'Testeur de mail';
L10n::$locales['Send a simple mail from admin'] = 'Envoyer un simple mail depuis l\'admin';

View File

@ -24,7 +24,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)
&& dcCore::app()->auth->isSuperAdmin();
return static::$init;
}
@ -35,6 +37,11 @@ class Backend extends dcNsProcess
return false;
}
// nullsafe
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->adminurl)) {
return false;
}
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
My::name(),
dcCore::app()->adminurl->get('admin.plugin.' . My::id()),

View File

@ -36,7 +36,9 @@ class Manage 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)
&& dcCore::app()->auth->isSuperAdmin();
return static::$init;
}
@ -47,6 +49,11 @@ class Manage extends dcNsProcess
return false;
}
// nullsafe
if (is_null(dcCore::app()->adminurl)) {
return false;
}
$active_headers = !empty($_POST['active_headers']);
$mail_to = $_POST['mail_to'] ?? '';
$mail_subject = $_POST['mail_subject'] ?? '';
@ -126,6 +133,11 @@ class Manage extends dcNsProcess
private static function getHeaders(): array
{
// nullsafe
if (is_null(dcCore::app()->blog)) {
return [];
}
return [
'From: ' . Mail::B64Header(dcCore::app()->blog->name) .
'<no-reply@' . str_replace('http://', '', Http::getHost()) . ' >',