From 270af63abc7166ac800d1e6389826062d12de776 Mon Sep 17 00:00:00 2001 From: Vincent Calame Date: Fri, 5 Nov 2021 12:51:53 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20d'un=20test=20suppl=C3=A9mentaire=20pou?= =?UTF-8?q?r=20am=C3=A9liorer=20le=20rapport=20d'erreur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action/importer_emission.php | 13 +++++++++---- libreavous_fonctions.php | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/action/importer_emission.php b/action/importer_emission.php index 3302398..4c4f334 100644 --- a/action/importer_emission.php +++ b/action/importer_emission.php @@ -34,10 +34,15 @@ function action_importer_emission_dist($arg = null) { $ogg_size = ""; $mp3_size = ""; try { - $jsonContents = file_get_contents("https://forge.april.org/libreavous/lav-outils/raw/branch/master/podcasts/config/lav-".$code_emission.".json"); - $json = json_decode($jsonContents, true); - if (!$json) { - $erreurs[] = "JSON incorrect : https://forge.april.org/libreavous/lav-outils/raw/branch/master/podcasts/config/lav-".$code_emission.".json"; + $jsonUrl = "https://forge.april.org/libreavous/lav-outils/raw/branch/master/podcasts/config/lav-".$code_emission.".json"; + $jsonContents = file_get_contents($jsonUrl); + if ($jsonContents === false) { + $erreurs[] = "Erreur d'accès au fichier JSON :".$jsonUrl; + } else { + $json = json_decode($jsonContents, true); + if (!$json) { + $erreurs[] = "JSON incorrect :".$jsonUrl; + } } } catch (Exception $e) { $erreurs[] = $e->getMessage(); diff --git a/libreavous_fonctions.php b/libreavous_fonctions.php index 0e2159e..0cec66b 100644 --- a/libreavous_fonctions.php +++ b/libreavous_fonctions.php @@ -99,10 +99,15 @@ function libreavous_import_run($id_article) { $ogg_size = ""; $mp3_size = ""; try { - $jsonContents = file_get_contents("https://forge.april.org/libreavous/lav-outils/raw/branch/master/podcasts/config/lav-".$code_emission.".json"); - $json = json_decode($jsonContents, true); - if (!$json) { - $erreurs[] = "JSON incorrect : https://forge.april.org/libreavous/lav-outils/raw/branch/master/podcasts/config/lav-".$code_emission.".json"; + $jsonUrl = "https://forge.april.org/libreavous/lav-outils/raw/branch/master/podcasts/config/lav-".$code_emission.".json"; + $jsonContents = file_get_contents($jsonUrl); + if ($jsonContents === false) { + $erreurs[] = "Erreur d'accès au fichier JSON :".$jsonUrl; + } else { + $json = json_decode($jsonContents, true); + if (!$json) { + $erreurs[] = "JSON incorrect :".$jsonUrl; + } } } catch (Exception $e) { $erreurs[] = $e->getMessage();