Something is wrong in the nodeapi hook when updating a node. Using the devel module I've seen the following query:
SELECT rid, BIT_OR(grant_view) AS grant_view, BIT_OR(grant_update) AS grant_update, BIT_OR(grant_delete) AS grant_delete FROM drupal_term_access WHERE tid IN ('Array') GROUP BY rid
Note te condition is wrong: IN ('Array'). This is build using the following code:
$result = db_query("SELECT rid, BIT_OR(grant_view) AS grant_view, BIT_OR(grant_update) AS grant_update, BIT_OR(grant_delete) AS grant_delete FROM {term_access} WHERE tid IN ('".implode("','",array_values($tids))."') GROUP BY rid");
So it seems array_values($tids) returns an Array? Not sure how, since $tids is defined a dew lines before from $node->taxonomy.
Sorry, I've been unable to see more than that.
Comments
Comment #1
markus_petrux commentedLooking at taxonomy_nodeapi, it calls the following when inserting/updating nodes:
At the end of this function there is the following code snippet:
So, yes. It seems $node->taxonomy may be nothing, an array of integers, or an array of arrays of integers, which is the case that leads to the problem I'm having here.
Comment #2
markus_petrux commentedok, I finally managed to find the fix. Please, see attached patch.
Cheers
Comment #3
markus_petrux commentedUpdated the patch, to remove an unnecessary DELETE done at insert node time. Note that for updates, that exact same DELETE statement was already done.
Comment #4
keve commentedMany thanks for the patch.
This is a good catch. I might never notice this :)
I rather remove DELETE statement from 'update' nodeapi. Since there is a fallthrough from 'insert' to 'update', and it should be done in both cases.
I also put a check for
is_array($node->taxonomy)Comment #5
(not verified) commented