Closed (fixed)
Project:
Views (for Drupal 7)
Version:
7.x-3.x-dev
Component:
User interface
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
15 Sep 2011 at 13:51 UTC
Updated:
2 Apr 2022 at 17:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dawehnerCould you try to redo the steps but clear the menu cache after enabling the view?
In general it would be cool if you could update to the latest version of views, because there are tons of bugs fixed already.
Comment #2
alan evans commentedThanks for the followup ...
Yes, tried a menu_rebuild() after enabling and it doesn't help ... debugging efforts are currently pointing to the enabled view (archive in my example) not getting pulled into the views_menu_alter hook by views_get_applicable_views (maybe it's somehow not deemed applicable ...).
I'll certainly give it a try on the dev branch.
Comment #3
alan evans commentedConfirmed issue seems also present on the latest dev *release* tarball (not sure if there's any difference between that and git master, but haven't tried git in any case).
I'm going to keep debugging this menu_alter a bit ...
Comment #4
alan evans commentedSpoke too soo - it definitely does come out of views_get_applicable_views. I'll avoid running commentaries for now until I have something more concrete.
Comment #5
alan evans commentedErm .... the disabled-and-enabled view's path has now started working, after about 10x menu_rebuild()s during debugging. It could have appeared any time after, say the 3rd though. Trying to repro on another one.
Comment #6
alan evans commentedNow appears to work after one menu_rebuild() post-enable.
It looks like I may have tested the menu_rebuild whilst still using the previous release codebase, then upgraded codebase after that test, confirmed that the view was still broken post-enable and didn't reconfirm after multiple menu_rebuilds
Comment #7
alan evans commented.... And again, no changes to code since last test, but this time multiple menu_rebuilds are not getting the /frontpage view to enable. I'll see if my logging caught anything of interest. I might have to continue this tomorrow.
We have a fantastically intermittent bug.
Comment #8
alan evans commentedI'm probably just losing my mind ... now none of my debug logging in views_menu_alter is firing at all, on multiple menu_rebuild()s. By all appearances, the menu is not being rebuilt at all, or at the very least the menu_alter is not running. The hook is definitely registered though:
Comment #9
alan evans commentedOK, so trying to debug menu_rebuild() now ...
The first 2 of these get logged, the 3rd one ('TRY') does not. Similarly, a watchdog at the end of the func just before the return does not get logged. Curious.
menu_rebuild() does return TRUE, so it does complete.
Comment #10
alan evans commentedSolved where the debug messages were going missing, using file logging from now on ...
So, looking at this, which is called on enable (views_ui.class.php):
there is already a menu_rebuild there, and it does get called (already confirmed this), I have a lot of debug logging still in there, so now time to work out why this menu_rebuild() doesn't do the job, but another manual rebuild later does.
Comment #11
alan evans commentedSo ... the issue appears to be, at the point where the menu_rebuild is called, as mentioned in #10, the view still has disabled => 1, so doesn't get considered during that menu_rebuild()... Will try and find out why that might be.
Comment #12
alan evans commentedSeems that during menu_rebuild, we're dealing with statically cached views. This can be solved in views.module like this:
Setting the $reset param to TRUE to refresh those cached objects. I've grepped ctools and views for other uses of this function and there aren't many. I'll probably ask advice on whether we always want to reset cache when calling this function (most consistent, but could cause performance problems if used a lot) or just on this one case (when calling views_get_applicable_views('uses hook menu'))
Comment #13
alan evans commentedAttached is the patch equivalent to the change pasted above and I've tested this and it does clear up the issue: it is now possible to enable disabled views and have the menu link work immediately.
What I'm not sure about is where this function gets called elsewhere. I know there is only one instance it is used in views, but several instances of views_get_applicable_views('returns context') appear in ctools. I can't say for sure whether this cache reset on every call to views_get_applicable_views is necessary for all calls, or whether limiting it to "uses hook menu" calls would be better.
Comment #14
alan evans commentedAttached is the patch equivalent to the change pasted above and I've tested this and it does clear up the issue: it is now possible to enable disabled views and have the menu link work immediately.
What I'm not sure about is where this function gets called elsewhere. I know there is only one instance it is used in views, but several instances of views_get_applicable_views('returns context') appear in ctools. I can't say for sure whether this cache reset on every call to views_get_applicable_views is necessary for all calls, or whether limiting it to "uses hook menu" calls would be better.
Comment #15
alan evans commentedApologies for the double post.
Comment #16
dawehnerThanks this patch seems to make sense.
Comment #17
alan evans commentedExcellent, thanks.
Comment #19
David_Rothstein commentedThis patch was committed, but seems to have been rolled back in #1342580: Views is aggressively resetting the ctools export cache every time it does a load all for possible performance impact.
Since the performance issue was already discussed above, let's just start by reuploading a patch and going from there.
Comment #20
David_Rothstein commentedIf we're worried about performance, we could, I suppose, just do what Alan was asking above (only resetting the cache for "uses hook menu" calls). If there's any doubt, I suppose that would be the safer way to go here.
Comment #21
dawehnerWell it's a question whether the fix introduced in #13 was actually a performance regression of reverting it was a regression, both is bad.
As doing it all the time will not just fly. What about using the idea from #20?
Set to "needs work" so it's not committed "because it makes sense".
Comment #22
dawehnerSo here is a small patch, which implements this idea.
Comment #24
damiankloip commentedIs this possibly related to #1507368: Add hook for when the view cache is invalidated and #1513126: Enabling a default view via ctools export ui requires a menu rebuild, if "variable_set('menu_rebuild_needed', TRUE)" is used, the menu is rebuilt in the next request anyway.
Comment #25
leewillis77 commentedI'd agree that #1513126: Enabling a default view via ctools export ui requires a menu rebuild is a duplicate. Not sure which of the two issues is more valuable to keep open - they both seem to have relevant history.
Comment #26
nileshlohar commentedReroll of patch #19 with latest release.
Comment #27
nileshlohar commentedComment #28
chris matthews commentedThe 2 year old patch in #26 to views.module does not apply to the latest views 7.x-3.x-dev and if still relevant needs to be rerolled.
Comment #29
Snehal Brahmbhatt commented@Chris Matthews, Please refer this updated rerolled patch & share your feedback on the same.
Comment #30
damienmckennaComment #34
damienmckennaComment #36
damienmckennaCommitted. Thanks everyone!