diff --git a/classes/DailyImageWidget.php b/classes/DailyImageWidget.php index bec4c58..aaa7fd7 100644 --- a/classes/DailyImageWidget.php +++ b/classes/DailyImageWidget.php @@ -171,8 +171,12 @@ class DailyImageWidget { list($timestamp, $cached_data) = $data; if (($timestamp + $this->_cache_time) > time()) { - $is_valid = (count(array_intersect()) == count($this->_valid_column_names)); + $is_valid = true; + foreach ($this->_valid_column_names as $field) { + if (!isset($cached_data[$field])) { $is_valid = false; break; } + } + return ($is_valid) ? $cached_data : false; } } } diff --git a/test/DailyImageWidgetTest.php b/test/DailyImageWidgetTest.php index 80d9bec..6c0687c 100644 --- a/test/DailyImageWidgetTest.php +++ b/test/DailyImageWidgetTest.php @@ -187,7 +187,7 @@ 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))); - $this->assertEquals(array($test_time, $this->sample_data), $this->diw->_get_cached_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))); @@ -195,8 +195,6 @@ class DailyImageWidgetTest extends PHPUnit_Framework_TestCase { update_option('hubblesite-daily-image-cache', null); $this->assertEquals(false, $this->diw->_get_cached_data()); - - $this->markTestIncomplete(); } }