For various reasons it may turn out that $param passed to node_load is wrong (on my testing site it was probably due to Views module). Of course other modules should make sure that $param is ok, but it's better to be safe than sorry, right? :).
When $param is null i get following errors:
Invalid argument supplied for foreach() in /www/neoni_www/www/subdomains/z2/modules/node/node.module on line 521.
implode() [<a href='function.implode'>function.implode</a>]: Invalid arguments passed in /www/neoni_www/www/subdomains/z2/modules/node/node.module on line 525.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 query: SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM node n INNER JOIN users u ON u.uid = n.uid INNER JOIN node_revisions r ON r.vid = n.vid WHERE in /www/neoni_www/www/subdomains/z2/includes/database.mysqli.inc on line 151.
First i changed code of node_load to check for array and make SQL not use 'WHERE' part, but then i thought it will always load some node, even tough it's not really the one which caller asked for. So i added early 'return NULL;' in case $param is not numeric and not array.
I guess that it could also check each of the $param values in case it is an array, but for now i'll wait for Your opinions about whole thing :).
| Comment | File | Size | Author |
|---|---|---|---|
| node.module.patch | 2.38 KB | ahwayakchih |
Comments
Comment #1
drummModules certainly should pay attention to what they pass to node_load() and not cause errors. Making the API more permissive is an API change and can only happen in a development version of Drupal, 5.x is currently stable.
Comment #2
ahwayakchih commentedBut i don't want to make it more permissive, only to make it safer. In case of weird/unsupported params it should return nothing (NULL), instead of trying to handle them anyway. IMHO such change makes it LESS permissive, not more :).
Comment #3
maria_zk commentedWell, i had the same issue for some reason and your patch worked me!So thank you very much!
Comment #4
subir_ghoshI tried using this patch and got this error:
I am using Drupal 5.7.
Comment #5
kmillecam commentedThanks much for this patch ahwayakchih,
I was getting really tired of my watchdog log fill up with errors because of this bug.
Kevin
Comment #6
damien tournoud commentedWe don't make the API more permissive, because it's always better to deal with problems than to ignore them.
This is a won't fix.
Comment #7
zcc_nz commentedWell it might be permissive but at least it fixes a problem.
If validation of code by developers is so poor that code is available that can cause such issues then I think any industrial standard software should be able to cleanly handle it in some way.
This patch does fix it as most 'users' would like.
Works for me!