diff --git a/action/acceder_document.php b/action/acceder_document.php index bc22bd7820f604d7c46b3549b45452383b88e7ab..7e6242c39cdb576e8dc8fcc5970944390dd1951e 100644 --- a/action/acceder_document.php +++ b/action/acceder_document.php @@ -23,6 +23,7 @@ include_spip('inc/headers'); // https://code.spip.net/@action_acceder_document_dist function action_acceder_document_dist() { + $doc = []; include_spip('inc/documents'); // $file exige pour eviter le scan id_document par id_document diff --git a/action/ajouter_documents.php b/action/ajouter_documents.php index e3767e7373a696e2b659e3408ad360a335ec4677..dfcd925b39f12194e15029f7f7e83353bc0ec431 100644 --- a/action/ajouter_documents.php +++ b/action/ajouter_documents.php @@ -100,7 +100,7 @@ function action_ajouter_un_document_dist($id_document, $file, $objet, $id_objet, define('_TITRER_DOCUMENTS', false); } - $titrer = isset($file['titrer']) ? $file['titrer'] : _TITRER_DOCUMENTS; + $titrer = $file['titrer'] ?? _TITRER_DOCUMENTS; $mode = ((isset($file['mode']) and $file['mode']) ? $file['mode'] : $mode); include_spip('inc/modifier'); diff --git a/action/changer_mode_document.php b/action/changer_mode_document.php index 3b31918cffd552967d39eb117cf4e7b3de58af28..b428b35203d89c7522c3f3dc249564e739a82530 100644 --- a/action/changer_mode_document.php +++ b/action/changer_mode_document.php @@ -33,7 +33,7 @@ function action_changer_mode_document_dist($id_document = null, $mode = null) { spip_log("action_changer_mode_document $arg pas compris"); } else { array_shift($r); - list($id_document, $mode) = $r; + [$id_document, $mode] = $r; } } diff --git a/action/desordonner_liens_documents.php b/action/desordonner_liens_documents.php index a77a619209b378f4fd19f4374ef62ab63f62b692..965bc37dba82561e7c37406165f4bd28f0534065 100644 --- a/action/desordonner_liens_documents.php +++ b/action/desordonner_liens_documents.php @@ -40,7 +40,7 @@ function action_desordonner_liens_documents_dist($arg = null) { } $arg = explode('-', $arg); - list($id_objet, $objet, $document) = $arg; + [$id_objet, $objet, $document] = $arg; if ( $id_objet = intval($id_objet) @@ -71,7 +71,7 @@ function desordonner_liens_documents($document, $objet, $id_objet) { if ($id_document = intval($document)) { desordonner_liens_document($id_document, $objet, $id_objet); } else { - list($image, $mode) = explode('/', $document); + [$image, $mode] = explode('/', $document); $image = ($image == 'I'); $typdoc = sql_in('docs.extension', ['gif', 'jpg', 'png'], $image ? '' : 'NOT'); diff --git a/action/dissocier_document.php b/action/dissocier_document.php index ea7527a9ee893a2fb23f062dac076a38cd3db5da..d3f4537ad532b4ea3f71d22427f9709019932a0e 100644 --- a/action/dissocier_document.php +++ b/action/dissocier_document.php @@ -42,11 +42,11 @@ function action_dissocier_document_dist($arg = null) { // attention au cas ou id_objet est negatif ! if (strncmp($arg, '-', 1) == 0) { $arg = explode('-', substr($arg, 1)); - list($id_objet, $objet, $document) = $arg; + [$id_objet, $objet, $document] = $arg; $id_objet = -$id_objet; } else { $arg = explode('-', $arg); - list($id_objet, $objet, $document) = $arg; + [$id_objet, $objet, $document] = $arg; } $suppr = $check = false; @@ -164,7 +164,7 @@ function dissocier_document($document, $objet, $id_objet, $supprime = false, $ch if ($id_document = intval($document)) { supprimer_lien_document($id_document, $objet, $id_objet, $supprime, $check); } else { - list($image, $mode) = explode('/', $document); + [$image, $mode] = explode('/', $document); $image = ($image == 'I'); $typdoc = sql_in('docs.extension', ['gif', 'jpg', 'png'], $image ? '' : 'NOT'); diff --git a/action/editer_document.php b/action/editer_document.php index eca564ed249c6a7fec171e3024bc64f1d8059536..eefc24a7e2a91d58551663e46d035402b436fda9 100644 --- a/action/editer_document.php +++ b/action/editer_document.php @@ -179,8 +179,8 @@ function document_modifier($id_document, $set = null) { */ function document_instituer($id_document, $champs = []) { - $statut = isset($champs['statut']) ? $champs['statut'] : null; - $date_publication = isset($champs['date_publication']) ? $champs['date_publication'] : null; + $statut = $champs['statut'] ?? null; + $date_publication = $champs['date_publication'] ?? null; if (isset($champs['parents'])) { medias_revision_document_parents($id_document, $champs['parents']); } @@ -233,7 +233,7 @@ function document_instituer($id_document, $champs = []) { ] ); - if (!count($champs)) { + if (!(is_countable($champs) ? count($champs) : 0)) { return false; } @@ -244,7 +244,7 @@ function document_instituer($id_document, $champs = []) { 'spip_documents_liens', "objet='rubrique' AND id_document=" . intval($id_document) ); - if (count($publier_rubriques)) { + if (is_countable($publier_rubriques) ? count($publier_rubriques) : 0) { include_spip('inc/rubriques'); foreach ($publier_rubriques as $r) { calculer_rubriques_if($r['id_objet'], ['statut' => $champs['statut']], $statut_ancien, false); diff --git a/action/ordonner_liens_documents.php b/action/ordonner_liens_documents.php index ca1a3ff34ee400b9afcebd62ab2b88a64a2cdaa8..8aaff03ae278b85177bf2135108da60310054b3d 100644 --- a/action/ordonner_liens_documents.php +++ b/action/ordonner_liens_documents.php @@ -42,7 +42,7 @@ function action_ordonner_liens_dist() { return envoyer_json_erreur(_T('medias:erreur_autorisation') . ' ' . _T('medias:erreur_deplacement_impossible')); } - list($_id_objet, $table_liens) = objet_associable($objet); + [$_id_objet, $table_liens] = objet_associable($objet); $success = $errors = []; @@ -93,7 +93,7 @@ function action_ordonner_liens_dist() { function envoyer_json_envoi($data) { header('Content-Type: application/json; charset=' . $GLOBALS['meta']['charset']); - echo json_encode($data); + echo json_encode($data, JSON_THROW_ON_ERROR); } function envoyer_json_erreur($msg) { diff --git a/action/supprimer_tous_orphelins.php b/action/supprimer_tous_orphelins.php index 6e3230b041ed1139535837f48196e9cf67b49df9..d1058a16c262f0791640d39642b56bc6514e2a8f 100644 --- a/action/supprimer_tous_orphelins.php +++ b/action/supprimer_tous_orphelins.php @@ -22,7 +22,7 @@ function action_supprimer_tous_orphelins() { $arg = $securiser_action(); //on recupere le contexte pour ne supprimer les orphelins que de ce dernier - list($media, $distant, $statut, $sanstitre) = explode('/', $arg); + [$media, $distant, $statut, $sanstitre] = explode('/', $arg); $where = []; //critere sur le media diff --git a/action/tourner.php b/action/tourner.php index aaeb395b31b13eb78bfdb430a80b31870c2dc6ee..0dd5784b7beadd7496e4bb2c38472c4da31dce1c 100644 --- a/action/tourner.php +++ b/action/tourner.php @@ -36,7 +36,7 @@ function action_tourner_dist($id_document = null, $angle = null) { spip_log("action_tourner_dist $arg pas compris"); } else { array_shift($r); - list($id_document, $angle) = $r; + [$id_document, $angle] = $r; } } if ($id_document and autoriser('modifier', 'document', $id_document)) { @@ -90,7 +90,7 @@ function action_tourner_post($id_document, $angle) { $res = filtrer('image_format', $res, $row['extension']); } - list($hauteur, $largeur) = taille_image($res); + [$hauteur, $largeur] = taille_image($res); $res = extraire_attribut($res, 'src'); include_spip('inc/getdocument'); diff --git a/formulaires/configurer_documents.php b/formulaires/configurer_documents.php index 82dccdd4e76cc8dfaaaee29e67c5962b97632bf8..3eba3a465578f06aba42788ea6e5192aeb13d5dd 100644 --- a/formulaires/configurer_documents.php +++ b/formulaires/configurer_documents.php @@ -34,7 +34,7 @@ function formulaires_configurer_documents_charger_dist() { 'documents_date', ] as $m ) { - $valeurs[$m] = isset($GLOBALS['meta'][$m]) ? $GLOBALS['meta'][$m] : ''; + $valeurs[$m] = $GLOBALS['meta'][$m] ?? ''; } $valeurs['documents_objets'] = explode(',', $valeurs['documents_objets']); diff --git a/formulaires/editer_document.php b/formulaires/editer_document.php index 0758cb17c43db64d525326f3b445871a6258d81a..f9fb065c0f6da57c811ba6406ffb527e4fb0f8b7 100644 --- a/formulaires/editer_document.php +++ b/formulaires/editer_document.php @@ -163,6 +163,7 @@ function formulaires_editer_document_traiter_dist( $row = [], $hidden = '' ) { + $rename = null; if (is_null(_request('parents'))) { set_request('parents', []); } diff --git a/formulaires/joindre_document.php b/formulaires/joindre_document.php index fdc901533b8cd2421bb6dbcef8281359ae4fb148..193217f7c472c14bbe9254126ea595f82e238a46 100644 --- a/formulaires/joindre_document.php +++ b/formulaires/joindre_document.php @@ -221,7 +221,7 @@ function formulaires_joindre_document_verifier_dist( and !_request('joindre_zip') and $contenu_zip = joindre_verifier_zip($files) ) { - list($fichiers, $erreurs, $tmp_zip) = $contenu_zip; + [$fichiers, $erreurs, $tmp_zip] = str_split($contenu_zip); if ($fichiers) { // on passe le md5 du fichier uniquement, on le retrouvera dans zip_to_clean de la session $token_zip = md5($tmp_zip); diff --git a/inc/documents.php b/inc/documents.php index 7f2a0b380a2843c35846375fcc30a929c4573863..ff147e5583a75582a9879d71ed1b9f64e019d835 100644 --- a/inc/documents.php +++ b/inc/documents.php @@ -230,7 +230,7 @@ function affiche_raccourci_doc($doc, $id, $align = '', $short = false) { $model = "<$doc$id$pipe>"; $text = $model; if ($short) { - $text = $align ? $align : $model; + $text = $align ?: $model; } $classes = 'btn btn_link btn_mini'; diff --git a/inc/joindre_document.php b/inc/joindre_document.php index 72ac41ce26c8d03c640ae11f1e8f971f14a1f079..d11e4f31fb3bb92f00b57bb187f26982c83eef91 100644 --- a/inc/joindre_document.php +++ b/inc/joindre_document.php @@ -28,7 +28,7 @@ function joindre_trouver_fichier_envoye() { // on est appele deux fois dans un hit, resservir ce qu'on a trouve a la verif // lorsqu'on est appelle au traitement - if (count($files)) { + if (is_countable($files) ? count($files) : 0) { return $files; } @@ -151,7 +151,7 @@ function joindre_trouver_fichier_envoye() { * string en cas d'erreur */ function joindre_trouver_http_post_files($name = null) { - $post = isset($_FILES) ? $_FILES : $GLOBALS['HTTP_POST_FILES']; + $post = $_FILES ?? $GLOBALS['HTTP_POST_FILES']; $files = []; if (is_array($post)) { foreach ($post as $input_name => $file) { @@ -159,7 +159,7 @@ function joindre_trouver_http_post_files($name = null) { continue; } if (is_array($file['name'])) { - while (count($file['name'])) { + while (is_countable($file['name']) ? count($file['name']) : 0) { $test = [ 'input_name' => $input_name, 'error' => array_shift($file['error']), @@ -200,6 +200,7 @@ function joindre_trouver_http_post_files($name = null) { // pour les autres erreurs renvoie le message d'erreur function joindre_upload_error($error) { + $msg = null; if (!$error) { return false; } diff --git a/inc/verifier_taille_document_acceptable.php b/inc/verifier_taille_document_acceptable.php index 70f80f19339b547b69e45ffe0f5b9621f816c340..072ab8369b7b242f193b8f1bdc8dd6a53b59800e 100644 --- a/inc/verifier_taille_document_acceptable.php +++ b/inc/verifier_taille_document_acceptable.php @@ -93,13 +93,13 @@ function medias_verifier_largeur_hauteur_image(&$infos, $max_width = null, $max_ // on met directement a la taille maxi a la volee if (isset($GLOBALS['meta']['creer_preview']) and $GLOBALS['meta']['creer_preview'] == 'oui') { include_spip('inc/filtres'); - $img = filtrer('image_reduire', $infos['fichier'], $max_width ? $max_width : '*', $max_height ? $max_height : '*'); + $img = filtrer('image_reduire', $infos['fichier'], $max_width ?: '*', $max_height ?: '*'); $img = extraire_attribut($img, 'src'); $img = supprimer_timestamp($img); if (@file_exists($img) and $img !== $infos['fichier']) { spip_unlink($infos['fichier']); @rename($img, $infos['fichier']); - list($h, $w) = taille_image($infos['fichier'], true); + [$h, $w] = taille_image($infos['fichier'], true); $infos['largeur'] = $w; $infos['hauteur'] = $h; $infos['taille'] = @filesize($infos['fichier']); diff --git a/medias_fonctions.php b/medias_fonctions.php index 7a41d70de76ffb13a4fbf3ed756ba91d4286a297..2f9ba73a5c806ad493ab89fc0dc534e6150b7f11 100644 --- a/medias_fonctions.php +++ b/medias_fonctions.php @@ -330,8 +330,8 @@ function medias_lister_methodes_upload($env) { $methodes['distant'] = ['label_lien' => _T('medias:bouton_download_sur_le_web'),'label_bouton' => _T('bouton_choisir')]; // pipeline pour les méthodes d'upload - $objet = isset($env['objet']) ? $env['objet'] : ''; - $id_objet = isset($env['id_objet']) ? $env['id_objet'] : ''; + $objet = $env['objet'] ?? ''; + $id_objet = $env['id_objet'] ?? ''; $methodes = pipeline( 'medias_methodes_upload', diff --git a/medias_pipelines.php b/medias_pipelines.php index a706202ecc8105b749dbed8bbdd974476080f058..c58050cf6c62e2c744adb79783bc06c13a417156 100644 --- a/medias_pipelines.php +++ b/medias_pipelines.php @@ -65,7 +65,7 @@ function medias_post_insertion($flux) { $objet = objet_type($flux['args']['table']); $id_objet = $flux['args']['id_objet']; - $id_auteur = isset($GLOBALS['visiteur_session']['id_auteur']) ? $GLOBALS['visiteur_session']['id_auteur'] : 0; + $id_auteur = $GLOBALS['visiteur_session']['id_auteur'] ?? 0; include_spip('inc/autoriser'); @@ -132,7 +132,7 @@ function medias_configurer_liste_metas($config) { **/ function medias_post_edition($flux) { // le serveur n'est pas toujours la - $serveur = (isset($flux['args']['serveur']) ? $flux['args']['serveur'] : ''); + $serveur = ($flux['args']['serveur'] ?? ''); // si on ajoute un document, mettre son statut a jour if (isset($flux['args']['action']) and $flux['args']['action'] == 'ajouter_document') { include_spip('action/editer_document'); @@ -140,12 +140,11 @@ function medias_post_edition($flux) { document_instituer($flux['args']['id_objet']); } // si on institue un objet, mettre ses documents lies a jour elseif (isset($flux['args']['table']) and $flux['args']['table'] !== 'spip_documents') { - $type = isset($flux['args']['type']) ? $flux['args']['type'] : objet_type($flux['args']['table']); + $type = $flux['args']['type'] ?? objet_type($flux['args']['table']); // verifier d'abord les doublons ! include_spip('inc/autoriser'); if (autoriser('autoassocierdocument', $type, $flux['args']['id_objet'])) { - $table_objet = isset($flux['args']['table_objet']) ? - $flux['args']['table_objet'] : table_objet($flux['args']['table'], $serveur); + $table_objet = $flux['args']['table_objet'] ?? table_objet($flux['args']['table'], $serveur); $marquer_doublons_doc = charger_fonction('marquer_doublons_doc', 'inc'); $marquer_doublons_doc( $flux['data'], diff --git a/metadata/video.php b/metadata/video.php index 0f7339a06f6229eec38fb296c4132fc64618725f..a4437b7a9d1fe675c2882505dbbea5a26f9ba2b3 100644 --- a/metadata/video.php +++ b/metadata/video.php @@ -25,6 +25,7 @@ if (!defined('_ECRIRE_INC_VERSION')) { * Le tableau comprenant les différentes metas à mettre en base */ function metadata_video($file) { + $id3 = []; $meta = []; include_spip('lib/getid3/getid3');