I'm getting the error below in my watchdog logs on every cron run (don't know specifically when it started). It seems that image_resize_filter is trying to remove a directory, and when the amazon stream wrapper tries to delete it, something goes wrong.

Haven't had much time to debug, but didn't know if this was something other people may have experienced. (See, specifically, the rmdir() part and DELETE FROM...

Exception: exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 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' in /home/admin/domains/flocknote.com/includes/database/database.inc:2136 Stack trace: #0 /home/admin/domains/flocknote.com/includes/database/database.inc(2136): PDOStatement->execute(Array) #1 /home/admin/domains/flocknote.com/includes/database/database.inc(664): DatabaseStatementBase->execute(Array, Array) #2 /home/admin/domains/flocknote.com/includes/database/query.inc(857): DatabaseConnection->query('DELETE FROM {am...', Array, Array) #3 /home/admin/domains/flocknote.com/sites/all/modules/amazons3/AmazonS3StreamWrapper.inc(710): DeleteQuery->execute() #4 [internal function]: AmazonS3StreamWrapper->rmdir('s3://resize/ima...', 8) #5 /home/admin/domains/flocknote.com/sites/all/modules/image_resize_filter/image_resize_filter.module(613): rmdir('s3://resize/ima...') #6 /home/admin/domains/flocknote.com/sites/all/modules/image_resize_filter/image_resize_filter.module(75): image_resize_filter_delete_derivatives('s3://images/for...') #7 [internal function]: image_resize_filter_file_delete(Object(stdClass)) #8 /home/admin/domains/flocknote.com/includes/module.inc(823): call_user_func_array('image_resize_fi...', Array) #9 /home/admin/domains/flocknote.com/includes/file.inc(1253): module_invoke_all('file_delete', Object(stdClass)) #10 
...
CommentFileSizeAuthor
#4 1653316-4-rmdir-fix.patch590 bytesgeerlingguy

Comments

geerlingguy’s picture

It looks like the problem is something in the query on line 710 of AmazonS3StreamWrapper.inc:

db_delete('amazons3_file')->condition($or)->execute();

It seems that S3 is trying to delete something that doesn't exist in the database, perhaps? I can't see the entire database query, though, so I can't quite tell what's going wrong. Still getting this error every time system_cron() runs.

geerlingguy’s picture

Title: Getting PDOException when trying to delete a directory on S3 with image_resize_filter » Getting PDOException during system_cron()

Updating title to reflect more specifically what's going on; it doesn't seem to be a problem caused by image_resize_filter.

geerlingguy’s picture

Title: Getting PDOException during system_cron() » Getting PDOException during system_cron() and when deleting files

I'm also getting the following error whenever a user tries removing a file in an imagefield and saving a node:

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 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: DELETE FROM {amazons3_file} WHERE (); Array ( ) in AmazonS3StreamWrapper->rmdir() (line 710 of ~/sites/all/modules/amazons3/AmazonS3StreamWrapper.inc).

It looks like something's a bit screwy with the {amazons3_file} table, possibly related to an upgrade issue related to #1291628: Reduce calls to S3?

geerlingguy’s picture

Status: Active » Needs review
StatusFileSize
new590 bytes

I found that the problem is that, in certain cases, the $objects variable is actually an empty array, and the db_or() is never set properly, resulting in the PDOException.

If you simply add a condition (see attached patch) to make sure the $objects array has something in it, the problem seems to be resolved.

aasarava’s picture

Funny, I just fixed this and was going to submit a patch. Do we need to check if $objects is an array? Seems like you can get rid of that part and just simplify by using the empty() check, since that looks for empty arrays.

if (!empty($objects)) {
alexgreyhead’s picture

The patch in #4 worked for me too - I'm working with unmanaged files on S3 and file_unmanaged_delete_recursive was triggering errors.

Many thanks! =o)

Al

nikkubhai’s picture

Status: Needs review » Reviewed & tested by the community
justafish’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, committed!

Status: Fixed » Closed (fixed)

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