diff --git a/ecrire/action/cookie.php b/ecrire/action/cookie.php index 27d40d43447989ab604eac6e5f4ac06a52a59848..b004d64580c6b47e666463f4f77068f70d83d0a5 100644 --- a/ecrire/action/cookie.php +++ b/ecrire/action/cookie.php @@ -99,7 +99,7 @@ function action_cookie_dist($set_cookie_admin = null, $change_session = null) { ); } } else { - $cook = isset($_COOKIE['spip_admin']) ? $_COOKIE['spip_admin'] : ''; + $cook = $_COOKIE['spip_admin'] ?? ''; // Suppression cookie d'admin ? if ($set_cookie_admin == 'non') { if ($cook) { diff --git a/ecrire/action/editer_article.php b/ecrire/action/editer_article.php index 4043cc3073a5d4ca7c627d1a3e06f949f14d81b4..ac12ed424e603edfcd763afaabc2e64f46ecffff 100644 --- a/ecrire/action/editer_article.php +++ b/ecrire/action/editer_article.php @@ -181,8 +181,8 @@ function article_inserer($id_rubrique, $set = null) { // eviter $id_secteur = NULL (erreur sqlite) si la requete precedente echoue // cas de id_rubrique = -1 par exemple avec plugin "pages" - $id_secteur = isset($row['id_secteur']) ? $row['id_secteur'] : 0; - $lang_rub = isset($row['lang']) ? $row['lang'] : ''; + $id_secteur = $row['id_secteur'] ?? 0; + $lang_rub = $row['lang'] ?? ''; $lang = ''; $choisie = 'non'; @@ -299,19 +299,17 @@ function article_instituer($id_article, $c, $calcul_rub = true) { $date_ancienne = $date = $row['date']; $champs = []; - $d = isset($c['date']) ? $c['date'] : null; - $s = isset($c['statut']) ? $c['statut'] : $statut; + $d = $c['date'] ?? null; + $s = $c['statut'] ?? $statut; // cf autorisations dans inc/instituer_article if ($s != $statut or ($d and $d != $date)) { if (autoriser('publierdans', 'rubrique', $id_rubrique)) { $statut = $champs['statut'] = $s; + } elseif (autoriser('modifier', 'article', $id_article) and $s != 'publie') { + $statut = $champs['statut'] = $s; } else { - if (autoriser('modifier', 'article', $id_article) and $s != 'publie') { - $statut = $champs['statut'] = $s; - } else { - spip_log("editer_article $id_article refus " . join(' ', $c)); - } + spip_log("editer_article $id_article refus " . join(' ', $c)); } // En cas de publication, fixer la date a "maintenant" diff --git a/ecrire/auth/ldap.php b/ecrire/auth/ldap.php index b0e8c6438c5cef8a6abc4a13e7a14ec2c5e2a27c..4a05e2c9418c621021efc5cacbbc21b589d5763c 100644 --- a/ecrire/auth/ldap.php +++ b/ecrire/auth/ldap.php @@ -167,9 +167,9 @@ function auth_ldap_search($login, $pass, $checkpass = true, $serveur = '') { return ''; } - $ldap_link = isset($ldap['link']) ? $ldap['link'] : null; - $ldap_base = isset($ldap['base']) ? $ldap['base'] : null; - $desc = isset($ldap['attributes']) && $ldap['attributes'] ? $ldap['attributes'] : $GLOBALS['ldap_attributes'] ; + $ldap_link = $ldap['link'] ?? null; + $ldap_base = $ldap['base'] ?? null; + $desc = !empty($ldap['attributes']) ? $ldap['attributes'] : $GLOBALS['ldap_attributes']; $logins = is_array($desc['login']) ? $desc['login'] : [$desc['login']]; diff --git a/ecrire/balise/formulaire_.php b/ecrire/balise/formulaire_.php index 9ec652622de2c7289233cfe7dd7a1fe2ef22ef41..5007b8ab4164e88382305a5b7262a90faabfd427 100644 --- a/ecrire/balise/formulaire_.php +++ b/ecrire/balise/formulaire_.php @@ -214,7 +214,7 @@ function balise_FORMULAIRE__contexte($form, $args) { if ($je_suis_poste) { $post = traiter_formulaires_dynamiques(true); $e = "erreurs_$form"; - $erreurs = isset($post[$e]) ? $post[$e] : []; + $erreurs = $post[$e] ?? []; $editable = "editable_$form"; $editable = (!isset($post[$e])) || count($erreurs) diff --git a/ecrire/balise/url_logout.php b/ecrire/balise/url_logout.php index 8f16fa955d4474aa2ce2da0877eab2e4afa464ac..b4707e27ea29e53006bed3155c30007831a5ad02 100644 --- a/ecrire/balise/url_logout.php +++ b/ecrire/balise/url_logout.php @@ -52,7 +52,7 @@ function balise_URL_LOGOUT($p) { * Liste (url) des arguments collectés. */ function balise_URL_LOGOUT_stat($args, $context_compil) { - $url = isset($args[0]) ? $args[0] : ''; + $url = $args[0] ?? ''; return [$url]; } diff --git a/ecrire/base/connect_sql.php b/ecrire/base/connect_sql.php index ffa442db8363db0a7530028ed541c5326d80742a..0a70e241999ba32a93459cd8baa97a92c7b6f292 100644 --- a/ecrire/base/connect_sql.php +++ b/ecrire/base/connect_sql.php @@ -116,7 +116,7 @@ function spip_connect($serveur = '', $version = '') { return $GLOBALS['connexions'][$index]; } - $GLOBALS['connexions'][$index]['spip_connect_version'] = isset($GLOBALS['spip_connect_version']) ? $GLOBALS['spip_connect_version'] : 0; + $GLOBALS['connexions'][$index]['spip_connect_version'] = $GLOBALS['spip_connect_version'] ?? 0; // initialisation de l'alphabet utilise dans les connexions SQL // si l'installation l'a determine. @@ -270,8 +270,7 @@ function spip_connect_db( } if (!$prefixe) { - $prefixe = isset($GLOBALS['table_prefix']) - ? $GLOBALS['table_prefix'] : $db; + $prefixe = $GLOBALS['table_prefix'] ?? $db; } $h = charger_fonction($type, 'req', true); if (!$h) { diff --git a/ecrire/base/dump.php b/ecrire/base/dump.php index 24bde30c0c01130dad2f1d5ede9c3782d7bd7dc3..6bacddcff6426ed32cfc9a553d65941a6b80d035 100644 --- a/ecrire/base/dump.php +++ b/ecrire/base/dump.php @@ -539,15 +539,15 @@ function base_preparer_table_dest($table, $desc, $serveur_dest, $init = false) { */ function base_copier_tables($status_file, $tables, $serveur_source, $serveur_dest, $options = []) { - $callback_progression = isset($options['callback_progression']) ? $options['callback_progression'] : ''; - $max_time = isset($options['max_time']) ? $options['max_time'] : 0; - $drop_source = isset($options['drop_source']) ? $options['drop_source'] : false; - $no_erase_dest = isset($options['no_erase_dest']) ? $options['no_erase_dest'] : []; - $where = isset($options['where']) ? $options['where'] : []; - $fonction_base_inserer = isset($options['fonction_base_inserer']) ? $options['fonction_base_inserer'] : 'inserer_copie'; - $desc_tables_dest = isset($options['desc_tables_dest']) ? $options['desc_tables_dest'] : []; - $racine_fonctions = (isset($options['racine_fonctions_dest']) ? $options['racine_fonctions_dest'] : 'base'); - $data_pool = (isset($options['data_pool']) ? $options['data_pool'] : 50 * 1024); + $callback_progression = $options['callback_progression'] ?? ''; + $max_time = $options['max_time'] ?? 0; + $drop_source = $options['drop_source'] ?? false; + $no_erase_dest = $options['no_erase_dest'] ?? []; + $where = $options['where'] ?? []; + $fonction_base_inserer = $options['fonction_base_inserer'] ?? 'inserer_copie'; + $desc_tables_dest = $options['desc_tables_dest'] ?? []; + $racine_fonctions = $options['racine_fonctions_dest'] ?? 'base'; + $data_pool = $options['data_pool'] ?? 50 * 1024; spip_log( 'Copier ' . count($tables) . " tables de '$serveur_source' vers '$serveur_dest'", diff --git a/ecrire/base/objets.php b/ecrire/base/objets.php index 767d9188c74c20debc6402df26b2a2a3a337395a..f504cc847b0d2565321f9ff0325029e4bc271ee4 100644 --- a/ecrire/base/objets.php +++ b/ecrire/base/objets.php @@ -808,12 +808,10 @@ function renseigner_table_objet_interfaces($table_sql, &$infos) { $infos['date'] = ((isset($infos['field']['date'])) ? 'date' : ''); } } - if (!isset($infos['statut'])) { - $infos['statut'] = isset($GLOBALS['table_statut'][$table_sql]) ? $GLOBALS['table_statut'][$table_sql] : ''; - } - if (!isset($infos['tables_jointures'])) { - $infos['tables_jointures'] = []; - } + + $infos['statut'] ??= $GLOBALS['table_statut'][$table_sql] ?? ''; + $infos['tables_jointures'] ??= []; + if (isset($GLOBALS['tables_jointures'][$table_sql])) { $infos['tables_jointures'] = array_merge($infos['tables_jointures'], $GLOBALS['tables_jointures'][$table_sql]); } @@ -1521,9 +1519,7 @@ function objet_lister_enfants($objet, $id_objet) { } else { // Les enfants sont stockés dans une table différente de l'objet parent. $table_enfant = $_methode_parent['table']; - $cle_objet_enfant = isset($_methode_parent['source_champ']) - ? $_methode_parent['source_champ'] - : id_table_objet($objet_enfant); + $cle_objet_enfant = $_methode_parent['source_champ'] ?? id_table_objet($objet_enfant); // S'il y a une condition supplémentaire if (isset($_methode_parent['table_condition'])) { diff --git a/ecrire/inc/auth.php b/ecrire/inc/auth.php index df6acb5373d961bec5f902ba521f8709e85b3077..76436bc6f0a088d16bf21662e13db98e14d78b17 100644 --- a/ecrire/inc/auth.php +++ b/ecrire/inc/auth.php @@ -324,13 +324,11 @@ function auth_a_loger() { */ function auth_trace($row, $date = null) { // Indiquer la connexion. A la minute pres ca suffit. - if (!is_numeric($connect_quand = isset($row['quand']) ? $row['quand'] : '')) { + if (!is_numeric($connect_quand = $row['quand'] ?? '')) { $connect_quand = strtotime($connect_quand); } - if (is_null($date)) { - $date = date('Y-m-d H:i:s'); - } + $date ??= date('Y-m-d H:i:s'); if (abs(strtotime($date) - $connect_quand) >= 60) { sql_updateq('spip_auteurs', ['en_ligne' => $date], 'id_auteur=' . intval($row['id_auteur'])); diff --git a/ecrire/inc/commencer_page.php b/ecrire/inc/commencer_page.php index 16d64212c53e05ce99d379e8cdb3dfe6e99a1404..917da982b28a1e3d83a3395e1cfa32295f814d17 100644 --- a/ecrire/inc/commencer_page.php +++ b/ecrire/inc/commencer_page.php @@ -157,13 +157,11 @@ function init_body($rubrique = 'accueil', $sous_rubrique = 'accueil', $id_rubriq * @return string Classes CSS (séparées par des espaces) */ function init_body_class() { - $prefs = isset($GLOBALS['visiteur_session']['prefs']) ? $GLOBALS['visiteur_session']['prefs'] : []; + $prefs = $GLOBALS['visiteur_session']['prefs'] ?? []; - $GLOBALS['spip_display'] = isset($prefs['display']) ? (int) $prefs['display'] : 2; + $GLOBALS['spip_display'] = intval($prefs['display'] ?? 2); $spip_display_navigation = isset($prefs['display_navigation']) ? spip_sanitize_classname($prefs['display_navigation']) : 'navigation_avec_icones'; - $spip_display_outils = isset($prefs['display_outils']) - ? ($prefs['display_outils'] ? 'navigation_avec_outils' : 'navigation_sans_outils') - : 'navigation_avec_outils'; + $spip_display_outils = ($prefs['display_outils'] ?? true) ? 'navigation_avec_outils' : 'navigation_sans_outils'; $GLOBALS['spip_ecran'] = isset($_COOKIE['spip_ecran']) ? spip_sanitize_classname($_COOKIE['spip_ecran']) : 'etroit'; $display_class = [ @@ -174,7 +172,7 @@ function init_body_class() { 3 => 'icones_img' ]; - $couleur = isset($prefs['couleur']) ? (int) $prefs['couleur'] : 2; + $couleur = intval($prefs['couleur'] ?? 2); $classes = $GLOBALS['spip_ecran'] . " spip-theme-colors-$couleur $spip_display_navigation $spip_display_outils " . $display_class[$GLOBALS['spip_display']]; return spip_sanitize_classname($classes); diff --git a/ecrire/inc/config.php b/ecrire/inc/config.php index ca55a6b1aa1b6f6c89f1b16b7e7118ee5ae1c191..d9ca628294c5c31accf76e6508b275125e3613d7 100644 --- a/ecrire/inc/config.php +++ b/ecrire/inc/config.php @@ -144,14 +144,14 @@ function lire_config($cfg = '', $def = null, $unserialize = true) { // le deserializer si demande // ou si on a besoin // d'un sous casier - $r = isset($r[$casier]) ? $r[$casier] : null; + $r = $r[$casier] ?? null; if (($unserialize or count($sous_casier)) and $r and is_string($r)) { $r = (($t = @unserialize($r)) === false ? $r : $t); } // aller chercher le sous_casier while (!is_null($r) and $casier = array_shift($sous_casier)) { - $r = isset($r[$casier]) ? $r[$casier] : null; + $r = $r[$casier] ?? null; } if (is_null($r)) { @@ -199,7 +199,7 @@ function ecrire_config($cfg, $store) { } // trouvons ou creons le pointeur sur le casier - $st = isset($GLOBALS[$table][$casier]) ? $GLOBALS[$table][$casier] : null; + $st = $GLOBALS[$table][$casier] ?? null; if (!is_array($st) and ($sous_casier or is_array($store))) { $st = unserialize($st); if ($st === false) { diff --git a/ecrire/inc/cvt_multietapes.php b/ecrire/inc/cvt_multietapes.php index 0fcbda2aa2db885f9ac236e1a195859c0975ade5..1e6b591540aeea5de830cb3548c2e7fd3589a1a6 100644 --- a/ecrire/inc/cvt_multietapes.php +++ b/ecrire/inc/cvt_multietapes.php @@ -284,7 +284,7 @@ function cvtmulti_formulaire_verifier_etapes($args, $erreurs) { $etape = min($etape, $etapes); #var_dump("prochaine etape $etape"); // retourner les erreurs de l'etape ciblee - $erreurs = isset($erreurs_etapes[$etape]) ? $erreurs_etapes[$etape] : []; + $erreurs = $erreurs_etapes[$etape] ?? []; // Ne pas se tromper dans le texte du message d'erreur : la clé '_etapes' n'est pas une erreur ! if ($erreurs) { if (!isset($erreurs['message_erreur'])) { diff --git a/ecrire/inc/distant.php b/ecrire/inc/distant.php index 9cac6068a1cfb35486fe9e446da3e0b774f298ae..7c865a4a97cef7a0d7c9cd2b47d3399838f0d38d 100644 --- a/ecrire/inc/distant.php +++ b/ecrire/inc/distant.php @@ -1123,16 +1123,16 @@ function distant_trouver_extension_selon_headers($source, $headers) { * @return string */ function need_proxy($host, $http_proxy = null, $http_noproxy = null) { - if (is_null($http_proxy)) { - $http_proxy = isset($GLOBALS['meta']['http_proxy']) ? $GLOBALS['meta']['http_proxy'] : null; - } + + $http_proxy ??= $GLOBALS['meta']['http_proxy'] ?? null; + // rien a faire si pas de proxy :) if (is_null($http_proxy) or !$http_proxy = trim($http_proxy)) { return ''; } if (is_null($http_noproxy)) { - $http_noproxy = isset($GLOBALS['meta']['http_noproxy']) ? $GLOBALS['meta']['http_noproxy'] : null; + $http_noproxy = $GLOBALS['meta']['http_noproxy'] ?? null; } // si pas d'exception, on retourne le proxy if (is_null($http_noproxy) or !$http_noproxy = trim($http_noproxy)) { @@ -1372,7 +1372,7 @@ function lance_requete( stream_set_timeout($f, _INC_DISTANT_CONNECT_TIMEOUT); } - $site = isset($GLOBALS['meta']['adresse_site']) ? $GLOBALS['meta']['adresse_site'] : ''; + $site = $GLOBALS['meta']['adresse_site'] ?? ''; $host_port = $host; if ($port != (in_array($scheme, ['tls','ssl']) ? 443 : 80)) { diff --git a/ecrire/inc/editer.php b/ecrire/inc/editer.php index 188525a3db6b293620eb13403a005ed48bcbf8c6..422a5fdeadc4b09686d66a18753a5b55660aca5b 100644 --- a/ecrire/inc/editer.php +++ b/ecrire/inc/editer.php @@ -741,7 +741,7 @@ function signaler_conflits_edition($conflits, $redirect = '') { $diffs = []; foreach ($conflits as $champ => $a) { // probleme de stockage ou conflit d'edition ? - $base = isset($a['save']) ? $a['save'] : $a['base']; + $base = $a['save'] ?? $a['base']; $diff = new Diff(new DiffTexte()); $n = preparer_diff($a['post']); diff --git a/ecrire/inc/filtres.php b/ecrire/inc/filtres.php index 8562da8ade4859613695e9de3cb94740a6666f70..57fb31dc4534e4e68bc0154f228b758d02b16e86 100644 --- a/ecrire/inc/filtres.php +++ b/ecrire/inc/filtres.php @@ -221,7 +221,7 @@ function version_vcs_courante($dir, $raw = false) { return $desc; } // affichage "GIT [master: abcdef]" - $commit = isset($desc['commit_short']) ? $desc['commit_short'] : $desc['commit']; + $commit = $desc['commit_short'] ?? $desc['commit']; if ($desc['branch']) { $commit = $desc['branch'] . ': ' . $commit; } @@ -4857,7 +4857,7 @@ function appliquer_traitement_champ($texte, $champ, $table_objet = '', $env = [] include_fichiers_fonctions(); $champ = strtoupper($champ); - $traitements = isset($GLOBALS['table_des_traitements'][$champ]) ? $GLOBALS['table_des_traitements'][$champ] : false; + $traitements = $GLOBALS['table_des_traitements'][$champ] ?? false; if (!$traitements or !is_array($traitements)) { return $texte; } @@ -4903,7 +4903,7 @@ function generer_lien_entite($id_objet, $objet, $longueur = 80, $connect = null) $titre = traiter_raccourci_titre($id_objet, $objet, $connect); // lorsque l'objet n'est plus declare (plugin desactive par exemple) // le raccourcis n'est plus valide - $titre = isset($titre['titre']) ? typo($titre['titre']) : ''; + $titre = typo($titre['titre']) ?? ''; // on essaye avec generer_info_entite ? if (!strlen($titre) and !$connect) { $titre = generer_info_entite($id_objet, $objet, 'titre'); diff --git a/ecrire/inc/filtres_ecrire.php b/ecrire/inc/filtres_ecrire.php index 3b5c9624b9242ea4e1a53bd60565ca9d2dfa4d2f..70b88319cc6f0ae380cf44bf1f962ebf20d6e0e4 100644 --- a/ecrire/inc/filtres_ecrire.php +++ b/ecrire/inc/filtres_ecrire.php @@ -49,9 +49,7 @@ function parametres_css_prive() { // un md5 des menus : si un menu change il faut maj la css $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); - $c = isset($GLOBALS['visiteur_session']['prefs']['couleur']) - ? $GLOBALS['visiteur_session']['prefs']['couleur'] - : 2; + $c = $GLOBALS['visiteur_session']['prefs']['couleur'] ?? 2; $couleurs = charger_fonction('couleurs', 'inc'); parse_str($couleurs($c), $c); @@ -486,7 +484,7 @@ function alertes_auteur($id_auteur) { $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); } - $a = isset($GLOBALS['meta']['message_alertes_auteurs']) ? $GLOBALS['meta']['message_alertes_auteurs'] : ''; + $a = $GLOBALS['meta']['message_alertes_auteurs'] ?? ''; if ( $a and is_array($a = unserialize($a)) diff --git a/ecrire/inc/filtres_images_mini.php b/ecrire/inc/filtres_images_mini.php index fc5a4cccd5be95625d206eec8dc01244160030ed..92e58533ca1e64f6eb9ae1c4f811b2798e322655 100644 --- a/ecrire/inc/filtres_images_mini.php +++ b/ecrire/inc/filtres_images_mini.php @@ -395,7 +395,7 @@ function image_passe_partout( } list($hauteur, $largeur) = taille_image($img); if ($taille_x === -1) { - $taille_x = isset($GLOBALS['meta']['taille_preview']) ? $GLOBALS['meta']['taille_preview'] : 150; + $taille_x = $GLOBALS['meta']['taille_preview'] ?? 150; } if ($taille_y === -1) { $taille_y = $taille_x; diff --git a/ecrire/inc/filtres_mini.php b/ecrire/inc/filtres_mini.php index a28df26416c6b84ac3b5a56c0872dcd3e299862b..abeb4a5e32933a09f833178960539f13f1d871a1 100644 --- a/ecrire/inc/filtres_mini.php +++ b/ecrire/inc/filtres_mini.php @@ -91,8 +91,8 @@ function suivre_lien($url, $lien) { $debut = $regs[1]; $dir = !strlen($regs[2]) ? '/' : $regs[2]; $mot = $regs[3]; - $get = isset($regs[4]) ? $regs[4] : ''; - $hash = isset($regs[5]) ? $regs[5] : ''; + $get = $regs[4] ?? ''; + $hash = $regs[5] ?? ''; } switch (substr($lien, 0, 1)) { case '/': diff --git a/ecrire/index.php b/ecrire/index.php index ed9d2a53d253b60c99af6d72023fb69330671977..0c77cbd35b285587a6373fb5bae049c9d4cc864a 100644 --- a/ecrire/index.php +++ b/ecrire/index.php @@ -147,9 +147,7 @@ elseif (!preg_match(',^[a-z4_][0-9a-z_-]*$,i', $exec)) { } // compatibilite ascendante : obsolete, ne plus utiliser -$GLOBALS['spip_display'] = isset($GLOBALS['visiteur_session']['prefs']['display']) - ? (int) $GLOBALS['visiteur_session']['prefs']['display'] - : 0; +$GLOBALS['spip_display'] = intval($GLOBALS['visiteur_session']['prefs']['display'] ?? 0); $GLOBALS['spip_ecran'] = isset($_COOKIE['spip_ecran']) ? preg_replace('/[^a-z0-9]/i', '', $_COOKIE['spip_ecran']) : 'etroit'; // si la langue est specifiee par cookie et ne correspond pas diff --git a/ecrire/public.php b/ecrire/public.php index aebd8e2cd2e9b749c04e158ad0b978c997c30892..20e483152f7df24ce7c9b2e9a8af42e637e2d378 100644 --- a/ecrire/public.php +++ b/ecrire/public.php @@ -123,7 +123,7 @@ if (isset($GLOBALS['_INC_PUBLIC']) and $GLOBALS['_INC_PUBLIC']) { // Content-Type ? if (!isset($page['entetes']['Content-Type'])) { - $charset = isset($GLOBALS['meta']['charset']) ? $GLOBALS['meta']['charset'] : 'utf-8'; + $charset = $GLOBALS['meta']['charset'] ?? 'utf-8'; $page['entetes']['Content-Type'] = 'text/html; charset=' . $charset; $html = true; } else {