Upgrading most fields to D7 from D6 are running beautifully, but images are you just not converting.

An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /batch?id=6077&op=do StatusText: Internal Server Error ResponseText: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'fid' cannot be null: INSERT INTO {file_usage} (fid, module, type, id, count) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4); Array ( [:db_insert_placeholder_0] => [:db_insert_placeholder_1] => file [:db_insert_placeholder_2] => node [:db_insert_placeholder_3] => 99 [:db_insert_placeholder_4] => 1 ) in file_usage_add() (line 663 of /home/public_html/d7/includes/file.inc).

User pictures all converted perfectly = folder 'sites/default/files/pictures'
Over 8000 images for node type 'articles' = folder = 'sites/default/files/articles' that are not converting

Have cleared all duplicate paths

Looking in phpMyAdmin

most images are NULL in 'content_field_image' (see attached screenshot)
images in 'file' are all good (see attached screenshot)

Been trying for days :) would most appreciate any suggestions.

Members fund testing for the Drupal project. Drupal Association Learn more


Liliplanet’s picture

25.78 KB
33.83 KB

Have deleted everything that was fid NULL in my content_field_image for the upgrade (pls see attached screenshot) .. no more NULL

still same error as #1 (: (see attached screenshot)

Maybe missing something fundamental here? Not good as sql, but trying :)

My goodness, the 7000+ D6 content type 'articles' are not going to be much good without their images and would love to upgrade.

Would appreciate any guidance :)

hdcwebteam’s picture

Have you checked that each field_image_fid in your content_field_image table has a corresponding fid in the files table?

I believe the migrate process will involve both tables, so if a null value is creeping in it could mean there's an actual null value in one of the rows, or a mismatch between those two tables.

Liliplanet’s picture

Thank you so much for your response hdcwebteam!

I've had a look and have 7,294 entries in content_field_image table and 4,377 entries in file table.

As mentioned in #1 there are many content_field_image fids that are NULL (and when I removed them) still not able to update

made sure that there are no duplicate paths with:

SELECT filepath, COUNT(filepath) as count FROM files GROUP BY filepath HAVING count > 1

and cleaning them with:

WHERE filepath='sites/default/files/articles/duplicates.jpg';

Is there perhaps an sql command to check as per your suggestion if "each field_image_fid in your content_field_image table has a corresponding fid in the files table"

or wishing :) able to rebuild all nodes that have an image in a new file folder or table?

I've had a look at http://drupal.org/project/filefield_paths

Do you perhaps think to rename the images with token values will clean up the database?

Would most appreciate any guidance on how to convert the images, and again thank you :)

hdcwebteam’s picture

I'm not great with SQL but try this:

select * from `content_field_image` where field_image_fid NOT IN (SELECT fid from `files`)

This *should* return zero results - in which case your problem lies elsewhere.

If you do get any results then those rows are referring to files which are missing.

It's almost certainly something to do with your data as I just migrated 1000 or so image fields successfully using 7.x-2.x-dev (30-July-2011) version of CCK.

Now if only I could get my date fields to work...

Liliplanet’s picture

Hi hdcwebteam,

Still trying to upgrade :) Been trying to do it manually deleting images, but there are so many ..

Your sql if fabulous and give me many rows, but what do I do with the results?

Deleting the rows doesn't fix it, so presuming there is more to be done?

Would so appreciate any assistance in how to find the duplicated and missing files, and most of all what to do when found. A detailed explanation of what to do (even if it is to find rows one-by-one), so that I can upgrade the 5000+ images.

hdcwebteam’s picture

All I can suggest for problem rows is to delete them (after backing up your database of course!).

1. If you didn't do this already, make sure your D6 site is fully up to date (update to latest CCK, imagefield etc modules) before attempting to migrate the fields.

2. Delete all those 'orphaned' results by changing "SELECT" to "DELETE"
delete * from `content_field_image` where field_image_fid NOT IN (SELECT fid from `files`)

3. Check none of the remaining content_field_image rows have a null fid - I think step 2 should get them, but just in case:
select * from `content_field_image` where field_image_fid = NULL

and if any results,

delete * from `content_field_image` where field_image_fid = NULL

4. Try the migrate again and see if you get the exact same error message.

timoguic’s picture

This problem drove me crazy for a couple of days until I found this post. Thanks hdcwebteam, you made my day.

kenorb’s picture