From 27bf2c7b35ccaed68ab9a11eb1f47546f74df8c7 Mon Sep 17 00:00:00 2001 From: Fil <fil@rezo.net> Date: Fri, 30 Mar 2012 20:08:11 +0000 Subject: [PATCH] report de [19087] mettre en cache le resultat du ping sur une URL distante --- ecrire/inc/distant.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ecrire/inc/distant.php b/ecrire/inc/distant.php index 10650d167c..c3c8eb8cbe 100644 --- a/ecrire/inc/distant.php +++ b/ecrire/inc/distant.php @@ -420,8 +420,18 @@ function fichier_copie_locale($source) { if (file_exists(_DIR_RACINE . $f)) return $f; } + // Ping pour voir si son extension est connue et autorisee - $path_parts = recuperer_infos_distantes($source,0,false) ; + // avec mise en cache du resultat du ping + + $cache = sous_repertoire(_DIR_CACHE,'rid').md5($source); + if (!@file_exists($cache) + OR !$path_parts = @unserialize(spip_file_get_contents($cache)) + OR _request('var_mode') == 'recalcul' + ) { + $path_parts = recuperer_infos_distantes($source,0,false) ; + ecrire_fichier($cache, serialize($path_parts)); + } $ext = $path_parts ? $path_parts['extension'] : ''; if ($ext AND sql_getfetsel("extension", "spip_types_documents", "extension=".sql_quote($ext))) { return nom_fichier_copie_locale($source, $ext); -- GitLab