[drupal-docs] [bug] hook_load can overwrite information: should be documented

fgm drupal-docs at drupal.org
Sun Oct 9 11:06:44 UTC 2005


Issue status update for 
http://drupal.org/node/33523
Post a follow up: 
http://drupal.org/project/comments/add/33523

 Project:      Documentation
 Version:      <none>
 Component:    Developer Guide
 Category:     bug reports
 Priority:     normal
 Assigned to:  Anonymous
 Reported by:  fgm
 Updated by:   fgm
 Status:       active

The description for hook_load says that It is called to allow the module
a chance to load extra information that it stores about a node. and that
the returned object will be merged with the passed-in $node to result in
an object containing both sets of properties.


This is not exactly what happens: node.module/node_load does not
exactly return the node containing both sets of properties, but the
passed-in properties, plus the extra properties added by the hook_load
implementation, which can replace the passed-in properties if the
returned object contains keys having the same name as the passed-in
properties, which means they are not only "extra" properties.


This means existing properties loaded in the first part of node_load
can be overwritten, or even removed by hook_load (using unset), which
should be
- either documented if this is the desired behaviour for the code,
- or avoided by sanitizing the return value of hook_load through
checking for duplicates with the passed-in values.


Page affected:
http://drupaldocs.org/api/head/function/node_load
http://drupaldocs.org/api/4.6/function/node_load




fgm




More information about the drupal-docs mailing list