switch to better option handling
This commit is contained in:
parent
cb4c7cd68e
commit
33ba3f3a42
@ -260,11 +260,8 @@ class DailyImageWidget {
|
||||
* @return array|boolean The cached data or false upon failure.
|
||||
*/
|
||||
function _get_cached_data() {
|
||||
$result = get_option('hubblesite-daily-image-cache');
|
||||
|
||||
if (is_string($result)) {
|
||||
if (($data = @unserialize($result)) !== false) {
|
||||
list($timestamp, $cached_data) = $data;
|
||||
if (($result = get_option('hubblesite-daily-image-cache')) !== false) {
|
||||
list($timestamp, $cached_data) = $result;
|
||||
|
||||
if (($timestamp + $this->_cache_time) > time()) {
|
||||
$is_valid = true;
|
||||
@ -278,7 +275,6 @@ class DailyImageWidget {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -256,11 +256,11 @@ class DailyImageWidgetTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
function testGetCachedData() {
|
||||
$test_time = time() + 86500;
|
||||
update_option('hubblesite-daily-image-cache', serialize(array($test_time, $this->sample_data)));
|
||||
update_option('hubblesite-daily-image-cache', array($test_time, $this->sample_data));
|
||||
$this->assertEquals($this->sample_data, $this->diw->_get_cached_data());
|
||||
|
||||
$test_time = time() - 86500;
|
||||
update_option('hubblesite-daily-image-cache', serialize(array($test_time, $this->sample_data)));
|
||||
update_option('hubblesite-daily-image-cache', array($test_time, $this->sample_data));
|
||||
$this->assertEquals(false, $this->diw->_get_cached_data());
|
||||
|
||||
update_option('hubblesite-daily-image-cache', null);
|
||||
|
Loading…
Reference in New Issue
Block a user