I have a situation where:
- Call views_get_view to retrieve a view
- Delete the view via $view->delete()
- Then later call views_get_view with $reset = TRUE
- The view is still returned
and I think it is because the cache is never cleared even if reset is TRUE. I'll explain below.
1299 static function &load($arg, $reset = FALSE) {
1300 static $cache = array();
1301
1302 // We want a NULL value to return TRUE here, so we can't use isset() or empty().
1303 if (!array_key_exists($arg, $cache) || $reset) {
1304 $result = db_select('views_view', 'v')
1305 ->fields('v')
1306 ->condition(is_numeric($arg) ? 'vid' : 'name', $arg)
1307 ->execute();
1308 foreach ($result as $data) {
1309 if (empty($data)) {
1310 $cache[$arg] = NULL;
1311 }
1312 else {
1313 $view = new view();
1314 $view->load_row($data);
1315 $view->type = t('Normal');
On line 1308 above, if the view is no longer in the DB but it is in cache line 1310 to clear the $cache will never get called b/c the query returns no rows and thus 1308 has noting to iterate on.
Will work up a patch for this shortly unless this was done intentionally.
Comments
Comment #1
febbraro commentedHere is the patch.
The thing that triggered this error was running the Features unit tests, within a single run it loads a default view, modifies it and saves it, then deletes it and makes sure the view is a default view again. It kept coming back as overridden b/c the cache was never getting cleared.
Comment #2
dawehnerThis test could be included into views as well. Some parts should really be tested.
Thanks for fixing this issue!
I'm just wondering why this issue is critical.
Something like a WSOD or a bug which removes a every-day-"use case" is critical. But that's just my oppinion.
Wrote a simpletest, commited this test to 6.x-3.x, too
Comment #3
febbraro commentedI think you're right, critical is overdoing it, seemed like a bigger deal at the time. :)
Thanks for the commit.