From ff2ac0a38c724f36b4a2a5ac99b94a6a4e8eef56 Mon Sep 17 00:00:00 2001 From: Cerdic <cedric@yterium.com> Date: Fri, 13 Aug 2021 10:49:22 +0200 Subject: [PATCH] Eviter des notices sur l'utilisation des balises #GET/#ENV/#SESSION : on utiliser l'operateur ?? et on evite des @ --- ecrire/inc/filtres.php | 5 +++-- ecrire/public/balises.php | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ecrire/inc/filtres.php b/ecrire/inc/filtres.php index a0e47f3f10..f390067821 100644 --- a/ecrire/inc/filtres.php +++ b/ecrire/inc/filtres.php @@ -3070,7 +3070,7 @@ function url_absolue_css($css) { function table_valeur($table, $cle, $defaut = '', $conserver_null = false) { foreach (explode('/', $cle) as $k) { - $table = is_string($table) ? @unserialize($table) : $table; + $table = (is_string($table) ? @unserialize($table) : $table); if (is_object($table)) { $table = (($k !== "") and isset($table->$k)) ? $table->$k : $defaut; @@ -3078,10 +3078,11 @@ function table_valeur($table, $cle, $defaut = '', $conserver_null = false) { if ($conserver_null) { $table = array_key_exists($k, $table) ? $table[$k] : $defaut; } else { - $table = isset($table[$k]) ? $table[$k] : $defaut; + $table = ($table[$k] ?? $defaut); } } else { $table = $defaut; + break; } } diff --git a/ecrire/public/balises.php b/ecrire/public/balises.php index e843138a4e..167125f2ee 100644 --- a/ecrire/public/balises.php +++ b/ecrire/public/balises.php @@ -1367,11 +1367,11 @@ function balise_ENV_dist($p, $src = null) { if ($src) { $p->code = '(is_array($a = (' . $src . ')) ? serialize($a) : "")'; } else { - $p->code = '@serialize($Pile[0])'; + $p->code = 'serialize($Pile[0]??[])'; } } else { if (!$src) { - $src = '@$Pile[0]'; + $src = '$Pile[0]??[]'; } if ($_sinon) { $p->code = "sinon(table_valeur($src, (string)$_nom, null), $_sinon)"; @@ -1481,7 +1481,7 @@ function balise_SESSION_dist($p) { ? 'balise_ENV' : 'balise_ENV_dist'; - $p = $f($p, '$GLOBALS["visiteur_session"]'); + $p = $f($p, '$GLOBALS["visiteur_session"]??[]'); return $p; } @@ -2172,9 +2172,9 @@ function balise_SET_dist($p) { function balise_GET_dist($p) { $p->interdire_scripts = false; // le contenu vient de #SET, donc il est de confiance if (function_exists('balise_ENV')) { - return balise_ENV($p, '$Pile["vars"]'); + return balise_ENV($p, '$Pile["vars"]??[]'); } else { - return balise_ENV_dist($p, '$Pile["vars"]'); + return balise_ENV_dist($p, '$Pile["vars"]??[]'); } } -- GitLab