Jump to:
| Project: | FileField |
| Version: | 6.x-3.0 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
The filefield_field_update() function in filefield_field.inc calls node_load() at line 163, as part of the hook_field process for $op='update'. However, in another (custom) module, I have a hook_nodeapi which invokes content_update() (in order to force "computed fields" to update). This causes an infinite recursion, however: content_update() invokes hook_field(), which invokes filefield_field_update(), which invokes node_load(), infinitely on the same nodes. The result is the error:
Fatal error: Maximum function nesting level of '100' reached, aborting!
The previous version of filefield did not invoke node_load() in filefield_field_update(), and it basically seems like a bad idea, since infinite recursions are very plausible there.
What's the fix here -- changing filefield to remove the node_load()? Or should I retool my other module so as not to call content_update?
Comments
#1
I wouldn't call this a "bug report" since it's a problem caused by another module. I'd say what your other module is doing is not standard behavior. You're calling a hook_update() on hook_nodeapi_load()? It seems wrong on a lot of levels. You realize that means that CCK is going to execute several of UPDATE queries for all that node's fields every time that node is loaded? That means just *viewing* the front page is going to fire dozens of update queries. I'd really recommend changing your other module's code.
#2
The purpose of the other module's hook_node_api is to force CCK 'computed fields' to update. Those fields' "computations" rely on other nodes so any changed node can theoretically change the computed field of another node. How would you recommend forcing those fields to re-compute?
#3
I don't think I'll be able to make a recommendation here, but I'll re-iterate this approach is extremely flawed. Generally I think the entire approach is incorrect as "update" hooks should never be fired on "load". Instead I'd suggest something that simply made appropriate computations on load given the available values, or call the very specific update function you need on load instead of blindly firing update hooks for all CCK fields on load.