When wysiwyg_imageupload is enabled, any time you delete a node, you will get the following error:

user warning: 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 'AS r USING wysiwyg_imageupload_entity AS e WHERE e.iid=r.iid AND nid=103' at line 1 query: DELETE FROM wysiwyg_imageupload_entity_revision AS r USING wysiwyg_imageupload_entity AS e WHERE e.iid=r.iid AND nid=103 in /home/dsnopek/prj/h2oscore/drupal/sites/all/modules/wysiwyg_imageupload/wysiwyg_imageupload.file.inc on line 207.

This is because the SQL isn't valid (at least under MySQL, I didn't test Postgres or any other db). Attached is a patch that fixes that SQL statement. The syntax for using DELETE with aliases is really strange! I had to really analyze the MySQL manual to figure it out.

I tested with Drupal 6.22, PHP 5.3 and MySQL 5.1.49.

Regards,
David.

CommentFileSizeAuthor
wysiwyg_imageupload-delete.patch685 bytesdsnopek

Comments

eugenmayer’s picture

Status: Needs review » Patch (to be ported)

AFAIK this will break postgresql once again, but anyway. Iam running into th same troubles and will apply the patch. Thank you for the contribution

dsnopek’s picture

What if the statement where written without aliases? I don't have Postgres to test and the SQL would definitely be uglier, but I think you might be able make a statment that worked on both just by using full table names...

eugenmayer’s picture

Well seeing #989324: Better support for PostgreSQL the old query was exactly the one you wrote, and those new ones fail on MYSQL. We had this ping-pong bug several times now. I will focus on MYSQL and only include a patch for Postgrsql if it seriously got tested on both server-types

dsnopek’s picture

Aha! Yeah, sounds good.

Just to clarify my thoughts about the "query without aliases", I'm going to post one here. No pressure to actually use it, but while it's still fresh in my brain I figure I'll get it in the issue queue for future generations. ;-)

  db_query('DELETE FROM {wysiwyg_imageupload_entity_revision} USING {wysiwyg_imageupload_entity_revision}, {wysiwyg_imageupload_entity} WHERE {wysiwyg_imageupload_entity}.iid={wysiwyg_imageupload_entity_revision}.iid AND nid=%d', $nid);

That query is valid under MySQL (I just tested it) and may work under Postgres because it isn't using the MySQL-specific alias syntax (but I haven't tested it).

See ya!
David.

eugenmayer’s picture

Status: Patch (to be ported) » Fixed

committed #4 tot he master, thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.