php - Node insert continues to call nodeapi even if query failed
I have a custom nodapi function for performing additional opporations when a type of content type is inserted. However, I've had the following error occur "Warning in test1\includes\common.inc on line 3538.". I've tracked this down several times to being an encoding issue, and I'm not sure how to resolve that though.
However, what I don't get is even though the query fails, nodeapi still gets called and I get a blank nid. This also causes other inserts to fail because nid and vid are 0 or null.
I understand that the causing issue is the encoding, but I don't understand why Drupal still runs nodeapi if the node insert (I believe) is failing and no nid or vid is produced.
Any help would be appreciated.
Greg.
Answer
Solution:
Take a look at
. Drupal runs the queries but doesn't check the result of the queries. So
hook_nodeapi
regardless of the node is actually saved in the database.Drupal could check the result of the query, but doing so would bring to much overhead, to a problem that only could be caused by incorrect database setup. Drupal requires a proper database setup, like it requires a webserver and PHP. It shouldn't be Drupal's job to check that these systems function properly.