Commit 4e7f0804 authored by Cerdic's avatar Cerdic

fix bug calculs des urls du service a mettre en cache si jamais il est fait...

fix bug calculs des urls du service a mettre en cache si jamais il est fait depuis un cron de ecrire/
parent 636dc820
......@@ -133,6 +133,10 @@ function offline_url_normalise($url, $url_base = '') {
$url = $parts['scheme'] . ':' . $url;
}
elseif(strpos($url,'://')===false) {
// les URLs relatives sont toujours par rapport a la racine du site
if (!$url_base) {
$url_base = url_absolue(_DIR_RACINE);
}
$url = url_absolue($url, $url_base);
}
return $url;
......@@ -201,7 +205,7 @@ function offline_urls_to_cache($build = false) {
$urls = array(
find_in_path("img/fallback.png"),
url_de_base(),
url_absolue(_DIR_RACINE),
offline_url_404_offline(),
);
......@@ -308,7 +312,9 @@ function offline_ressources_from_url($url, $force_refresh = false, $profondeur =
$r = array_filter($r);
return $r;
}
$url = offline_url_normalise($url);
spip_log("offline_ressources_from_url : $url","offline");
if (!$url) {
return array();
}
......@@ -404,11 +410,13 @@ function offline_build_services($force_refresh=false, $time_out=null) {
$urls_to_load = array(
0 => offline_urls_to_cache(false)
);
spip_log("offline_build_services:urls_to_load" . var_export($urls_to_load, true), 'offline');
ecrire_fichier($file_urls_load_progress, json_encode($urls_to_load));
}
if (!$urls_to_load = offline_build_urls($file_urls_load_progress, $force_refresh, $time_out)) {
$urls_to_load = offline_build_urls($file_urls_load_progress, $force_refresh, $time_out);
if ($urls_to_load === false) {
// on a pas fini, on reviendra
return false;
}
......@@ -468,6 +476,7 @@ function offline_background_build_services($force_refresh=false, $iteration=1) {
*/
function offline_build_urls($file_urls_load_progress, $force_refresh=false, $timeout=null, $profondeur_maxi = 5) {
//spip_log("offline_build_urls: $file_urls_load_progress", 'offline');
lire_fichier($file_urls_load_progress, $c);
if (!$c or !$urls_to_load = json_decode($c, true)) {
@unlink($file_urls_load_progress);
......@@ -521,6 +530,7 @@ function offline_build_urls($file_urls_load_progress, $force_refresh=false, $tim
$urls = $urls_to_load['all'];
$urls = array_filter($urls);
$urls = array_unique($urls);
//spip_log("offline_build_urls resultat : " . var_export($urls, true), 'offline');
return $urls;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment