Problem:
If an image is saved and the image toolkit fails to determine for example the width, the field is tried to be saved with the value "NULL" in the column for "width". This is not a correct integer value.

Steps to reproduce:
There are 2 ways to reproduce this:

- Add a node with an image field. Upload an image that is 0 bytes (for example). Make sure you actually click the upload button, so the ajax processing occurs.
- Click save.

The other way is this:
- Add a node with an image field. Upload an image that is 0 bytes.
- When you edit this node, it will never end up saving again.

Suggested solution:
Make sure we only save width and height if it is est to something sensible.

Original title (and report) by guaka:
General error: 1366 Incorrect integer value: '' for column 'field_image_width' at row 1

Comments

guaka’s picture

This is related: "Warning: array_merge(): Argument #1 is not an array in image_styles() (line 582 of modules/image/image.module)."

okokokok’s picture

Version: 7.9 » 7.22

The Warning: array_merge(): Argument #1 is not an array in image_styles() occurs sometimes, inside the node/x/edit form, right after the file is uploaded.

General error: 1366 always occurs right after the node is saved (so it's probably not saved).

File system and permissions look fine.

okokokok’s picture

fixed after choosing GD in admin/config/media/image-toolkit

would be nice if this would be handled more gracefully

joachim’s picture

Version: 7.22 » 7.x-dev

This can actually also occur if a user tries to upload an image that isn't one.

For instance, I wanted to try uploading a large image file, and as I didn't have one large enough I just took a 3MB PDF and changed the file extension. Trying to upload it got this error.

Obviously, this is PEBCAK, but the user should get an error message, not a crash.

chris dart’s picture

Issue summary: View changes

Kasper, what do you mean by "choosing GD in admin/config/media/image-toolkit"? This doesn't exist in my system, and I can't find a module with this name.

davi.uezono’s picture

Issue summary: View changes
StatusFileSize
new448 bytes

We were getting errors when trying to create new node with non-required image fields. Exactly the same scenario, after a D7 migration.
This fixed our problems. Try to execute the script on your site using drush.

cilefen’s picture

I tagged this issue for some needed issue summary updates.

eiriksm’s picture

Updated the IS.

eiriksm’s picture

Issue summary: View changes
eiriksm’s picture

Status: Active » Needs review
StatusFileSize
new1.27 KB

...and here is a patch that fixes the problem. Maybe needs tests?

eiriksm’s picture

Title: General error: 1366 Incorrect integer value: '' for column 'field_image_width' at row 1 » Not able to save nodes with empty files as images.
Issue summary: View changes
eiriksm’s picture

StatusFileSize
new33.04 KB

For the record. This error does not happen on Drupal 8 (at least not in the same way - that being, the site seemingly crashes in Drupal 7).

In Drupal 8 you are presented with this error (attached). Maybe not the best error message, but at least it does not crash your site.

cilefen’s picture

eiriksm’s picture

Not really. I guess that describes and covers the d8 part of it.

In D7 this will give you a "maintenence page" with the error message like the original issue title. Patch is for d7

davi.uezono’s picture

It seems to happen after migrating a website from Drupal 6 to Drupal 7 using those automatic migration scripts.
This issue is related to default_value of this fields, that tries to save an enpty string on Drupal 6 database, but the field on Drupal 7 database in an integer.

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.