From 4a578a7e0121157cd85b0e0cbb3254d2d340de22 Mon Sep 17 00:00:00 2001 From: atomaka Date: Fri, 14 Oct 2011 01:18:16 -0400 Subject: [PATCH] Deal with the possibility that our cache files might not currently exist. --- cronjobs/index_data.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cronjobs/index_data.php b/cronjobs/index_data.php index dcde5ad..769ffcf 100644 --- a/cronjobs/index_data.php +++ b/cronjobs/index_data.php @@ -25,8 +25,17 @@ $dataSources = array( 'wow' => 43200, ); -$cacheData = json_decode(file_get_contents($CACHE_FILE),true); -$sourceData = json_decode(file_get_contents($DATA_FILE),true); +if(file_exists($CACHE_FILE)) { + $cacheData = json_decode(file_get_contents($CACHE_FILE),true); +} else { + $cacheData = array(); +} +if(file_exists($DATA_FILE)) { + $sourceData = json_decode(file_get_contents($DATA_FILE),true); +} else { + $sourceData = array(); +} + foreach($dataSources as $dataSource=>$refreshTime) { // check last time the data was updated $lastModified = (array_key_exists($dataSource, $cacheData)) ?