Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.0-rc3
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
25 Sep 2008 at 02:17 UTC
Updated:
19 Oct 2008 at 08:12 UTC
I have a helper function that retrieves information from a view programmatically, processes the info and returns information to be added to a node.
If I hook nodeapi 'view' and run the function on the node, it works without any trouble. However, if I run the function on 'load' it times out and returns nothing. Originally, it caused php to exceed the memory limit of 32mb. After raising the limit, it now just times out to a white screen. I have traced this to happen when build() is called on the view.
Viewing the same view's page display is fine, and calling build() on it outside of nodeapi 'load' is fine.
Any ideas on what would be causing this?
Thank you in advance.
Comments
Comment #1
merlinofchaos commentedHave you checked to see if you're creating an infinite loop?
Comment #2
CPyle commentedIt does this when $view->build() is called even when I comment out everything else in the function except for loading the view and building it. The only thing I could think of would be if views at some point calls node_load on the original node when it is building the query, which would cause an infinite loop. I could try statically caching the view object and checking for its status before executing build() I suppose?
That might not solve the end problem but it may identify an infinite loop somewhere.
Update: I tried making the view object itself static. This does indeed fix an infinite loop wherein build() triggers a 'load' operation on the original object. I've made a workaround to only go through with the processing if the views object has not yet been created, and I can now load my node.
If there's a better way to get around this, or if you think I might be breaking something else by doing this, let me know, otherwise I'll set this to resolved after more testing.
Comment #3
CPyle commentedUpon finding that views handles it's own static object cache, I'm going to try a slightly different approach. Same general idea.
Update: Well, checking the $view->built variable seemed not to work as it appeared to be reset after reloading the object from cache. Reverted to previous method.
Comment #4
merlinofchaos commentedDid you determine where the load operation is being triggered? It seems likely it would be an argument validator or something along those lines. If this is the case, I would say that your call needs to be responsible to guard against loops (since it isn't a normal operation to build a view during node_load()). You can easily do this:
Marking as fixed; I don't believe this is a problem with Views in particular.
Comment #5
CPyle commentedYes, that is more or less what I ended up doing. So far it's had no negative effects on anything else that I've seen.
Comment #6
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.