Deal with the possibility that our cache files might not currently exist.

This commit is contained in:
Andrew Tomaka 2011-10-14 01:18:16 -04:00
parent ac6516bad7
commit 4a578a7e01

View file

@ -25,8 +25,17 @@ $dataSources = array(
'wow' => 43200, 'wow' => 43200,
); );
$cacheData = json_decode(file_get_contents($CACHE_FILE),true); if(file_exists($CACHE_FILE)) {
$sourceData = json_decode(file_get_contents($DATA_FILE),true); $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) { foreach($dataSources as $dataSource=>$refreshTime) {
// check last time the data was updated // check last time the data was updated
$lastModified = (array_key_exists($dataSource, $cacheData)) ? $lastModified = (array_key_exists($dataSource, $cacheData)) ?