I have the following problem. Everytime I submit a node without an imagefield image uploaded, I am getting the following message:

user warning: Column 'field_image_fid' cannot be null query: INSERT INTO content_field_image (vid, nid, delta, field_image_fid, field_image_list, field_image_data) VALUES (5067, 5067, 0, NULL, NULL, NULL) in /home/westkiin/public_html/sites/all/modules/cck/content.module on line 1198.

But if the image is uploaded, everything is fine, no user warning comes up.

Can anyone help?

I have the following modules installed: Content Construction Kit (CCK) 6.x-2.0, FileField 6.x-3.0-alpha5, ImageAPI 6.x-1.0, ImageCache 6.x-2.0-beta2, ImageField 6.x-3.0-alpha2.

Note: Posting it here since it's content module related.

Comments

yched’s picture

Project: Content Construction Kit (CCK) » ImageField
Version: 6.x-2.0 » 6.x-3.0-alpha2
Component: content.module » Code
Category: support » bug

It's because the item has no ['fid'] entry. It should at least be NULL.
AFAICT, CCK is supposed to take care of this if imagefield_is_empty() is correctly implemented.
Let's move this over to imagefield first.
I'm assuming you're running Imagefield alpha2, please change in the version of the issue if not.

yched’s picture

Scratch that, I should have paid closer attention to the error message. The issue is that imagefield's fid column doesn't allow NULL values.
With CCK D6, it should, CCK enforces storing empty values as NULL in all columns.
See http://drupal.org/node/191796#191796-fields

This should be modified in imagefield_image_field_settings_database_columns(), and there should be an update function to take care of this for D5 upgrades.
text_update_6001 can be used as a starting point.

andrus_k’s picture

The problem I described above comes up in both ImageField 3.0 alpha and dev. It is also important to mention that I upgraded my site from D5. I assume everything is fine on fresh install. So I am wondering whether it's an upgrade path issue and is it going to be fixed in later versions? Is there anyone else who had spotted this bug when you tried to upgrade?

alexanderpas’s picture

Priority: Normal » Critical
andrus_k’s picture

Status: Active » Fixed

Yahoo! I solved it myself. The problem occured after I did an upgrade of my old images as described here - http://drupal.org/node/286474#comment-988783. To fix this I needed to correct my imagefield default values in field_image_fid.

This solved my problem:

ALTER TABLE `content_field_image` CHANGE `field_image_fid` `field_image_fid` INT( 11 ) NULL DEFAULT NULL.

Status: Fixed » Closed (fixed)

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

philpro’s picture

To clarify for anyone not savvy with sql, you can manually fix these errors using php myadmin by finding the offending table(s)/column(s) in the error message(s) and editing them.

Edit them and change the Null value from "No" to "Yes" (or Null) and the Default value from "0" to "Null". You should see other columns in the table with similar defaults. I had two error messages, so I had to fix two different tables.