Skip to content
Extraits de code Groupes Projets
Valider a2637fde rédigé par marcimat's avatar marcimat
Parcourir les fichiers

PHP 8.1 #4968 : Deprecated-- sur set_spip_doc et get_spip_doc en tolérant une entrée null.

Deprecated-- sur controler_contenu lorsque c vaut false, il ne devrait pas être transformé en array automatiquement.
parent 1b1a95c1
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -29,12 +29,13 @@ if (!defined('_ECRIRE_INC_VERSION')) { ...@@ -29,12 +29,13 @@ if (!defined('_ECRIRE_INC_VERSION')) {
* @param string $fichier * @param string $fichier
* @return string * @return string
*/ */
function set_spip_doc($fichier) { function set_spip_doc(?string $fichier): string {
if (strpos($fichier, _DIR_IMG) === 0) { if ($fichier and strpos($fichier, _DIR_IMG) === 0) {
return substr($fichier, strlen(_DIR_IMG)); return substr($fichier, strlen(_DIR_IMG));
} else { } else {
return $fichier; // ex: fichier distant
} // ex: fichier distant return $fichier ?? '';
}
} }
/** /**
...@@ -45,7 +46,11 @@ function set_spip_doc($fichier) { ...@@ -45,7 +46,11 @@ function set_spip_doc($fichier) {
* @param string $fichier * @param string $fichier
* @return bool|string * @return bool|string
*/ */
function get_spip_doc($fichier) { function get_spip_doc(?string $fichier) {
if ($fichier === null) {
return false;
}
// fichier distant // fichier distant
if (tester_url_absolue($fichier)) { if (tester_url_absolue($fichier)) {
return $fichier; return $fichier;
...@@ -56,11 +61,9 @@ function get_spip_doc($fichier) { ...@@ -56,11 +61,9 @@ function get_spip_doc($fichier) {
return false; return false;
} }
$fichier = ( if (strncmp($fichier, _DIR_IMG, strlen(_DIR_IMG)) !== 0) {
strncmp($fichier, _DIR_IMG, strlen(_DIR_IMG)) != 0 $fichier = _DIR_IMG . $fichier;
) }
? _DIR_IMG . $fichier
: $fichier;
// fichier normal // fichier normal
return $fichier; return $fichier;
......
...@@ -548,6 +548,7 @@ function controler_contenu($type, $id, $options = [], $c = false, $serveur = '') ...@@ -548,6 +548,7 @@ function controler_contenu($type, $id, $options = [], $c = false, $serveur = '')
// Appels incomplets (sans $c) // Appels incomplets (sans $c)
if (!is_array($c)) { if (!is_array($c)) {
$c = [];
foreach ($desc['field'] as $champ => $ignore) { foreach ($desc['field'] as $champ => $ignore) {
if (_request($champ)) { if (_request($champ)) {
$c[$champ] = _request($champ); $c[$champ] = _request($champ);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter