From 529fcdc81dac2680cced29844861607c3dd506e8 Mon Sep 17 00:00:00 2001 From: atomaka Date: Mon, 17 Oct 2011 21:01:30 -0400 Subject: [PATCH] Make sure not to write data unless we need to. --- cronjobs/index_data.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cronjobs/index_data.php b/cronjobs/index_data.php index 2832ded..6627b1a 100644 --- a/cronjobs/index_data.php +++ b/cronjobs/index_data.php @@ -61,14 +61,16 @@ foreach($dataSources as $dataSource=>$refreshTime) { if(time() - $lastModified > $refreshTime) { $cacheData[$dataSource] = time(); - $sourceData = call_user_func($dataSource); + $data = call_user_func($dataSource); + + if($data != false) { + echo 'updating ' . $dataSource . '
'; + $sourceData[$dataSource] = $data; + } else { + echo 'failed ' . $dataSource . '
'; + $cacheData[$dataSource] = 0; + } } - - if($sourceData != false) { - $sourceData[$dataSource] = $sourceData; - } else { - $cacheData[$dataSource] = 0; - } } file_put_contents(CACHE,json_encode($cacheData));