I'm not exactly sure the mechanics behind why, but for some reason various view paths from the menu_router table disappear. After doing a clear menu cache they come back. Has anyone reported this before? I assumed it was a bug in drupal core, but after further investigation only views where disappearing from various menus.

I sometimes get a 404 or 403 on random view paths. Once again flushing the menu cache fixes this.

Code in question
views_menu_alter()
view -> execute_hook_menu()
views_plugin_display_page -> execute_hook_menu()

CommentFileSizeAuthor
#2 views-1003716.patch1.16 KBmikeytown2

Comments

mikeytown2’s picture

Version: 6.x-2.x-dev » 6.x-2.11
Status: Needs review » Active

Been thinking about this... almost all of my views are in code; thus I think the loading views from code might not work 100% if the cache is being flushed at that instant.
views_get_applicable_views() calls views_get_all_views(). The list of views get loaded via view::load_views() and by views_discover_default_views(). views_discover_default_views() appears to load views in code.

views/includes/cache.inc gets loaded; so the _views_discover_default_views function is available. In here views_cache_get('views_default_views_index', TRUE) is called. Once the views index is grabbed, it then grabs each view from the cache. Right here we have a problem. We could grab the index but 1/2 though grabbing the views from the cache; the cache could be erased. That means the rest of the views do not get loaded.

Lets say views_cache_get is now returning FALSE for the 1/2 half of your views in code. Now that means none of the missing views from the cache will be loaded into the menu router. What's needed is a fallback for this condition.

  $data = views_cache_get('views_default:' . $view_name, TRUE);
  if (isset($data->data) && is_object($data->data)) {
    $cache[$view_name] = $data->data;
  } 

Seems like if one of the views that was in the index is missing assume cache is bad you must rely on code to get all the views.

Now that I've figured this out; patch to come soon.

mikeytown2’s picture

Title: views_menu_alter fails sometimes » views_menu_alter fails sometimes; views_cache_get() issue in _views_discover_default_views()
Priority: Normal » Major
Status: Active » Needs review
StatusFileSize
new1.16 KB
mikeytown2’s picture

Version: 6.x-2.11 » 6.x-2.x-dev
merlinofchaos’s picture

Version: 6.x-2.11 » 6.x-2.x-dev
Status: Active » Needs review

I think there's another issue trying to deal with exactly this, though it's phrased differently. I don't know it offhand, too weary (newborns eat sleep) to look right now, but take a look through the needs review/needs work queue. I'm sure it's been touched within the last 2 weeks.

mikeytown2’s picture

Status: Needs review » Closed (duplicate)