Problem

After upgrading to 7.14, you can receive the error:

Notice: Undefined index: default_image in image_field_prepare_view() (line 207 of \modules\image\image.field.inc).

Solution

A patch to fix this has been committed to 7.x and will be available in 7.15. In the meantime, visiting the image field settings form and clicking Save will resolve the issue.

Original report by pgglass

// Text of original report here.
(for legacy issues whose initial post was not the issue summary)

Just upgraded to Drupal 7.14 and immediately received the following error:

Notice: Undefined index: default_image in image_field_prepare_view() (line 207 of C:\Users\Philip Glass\Sites\upofa\modules\image\image.field.inc).

Nothing else to tell... I just simply upgraded and did nothing else.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pgglass’s picture

Component: base system » image system
sun’s picture

Component: image system » image.module

http://api.drupal.org/api/drupal/modules!image!image.field.inc/function/image_field_prepare_view/7

The initial condition needs to be changed into !empty($field['settings']['default_image'])

tim.plunkett’s picture

Status: Active » Needs review
FileSize
639 bytes

Makes sense.
Are we sure it won't hurt to have one for the elseif as well?

tim.plunkett’s picture

FileSize
821 bytes

Let's be explicit here.

sun’s picture

Status: Needs review » Reviewed & tested by the community

Thanks :)

Would probably be a good idea to open a follow-up issue to grep for all $field['settings'] and $instance['settings'] throughout core. I can only guess that most of the field type modules wrongly assume that all of their settings always exist. :(

benjy’s picture

subscribe, same error here.

batigol’s picture

Same here.

webchick’s picture

Version: 7.14 » 8.x-dev
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests, +Novice

Great. Thanks for the fast fix!

I don't mind committing this as a hotfix really, but I'm wondering if it's possible to add test coverage for this. I think the answer's no, because it only comes up on a 7.x => 7.14 upgrade but tagging just to see.

Also, we need a 8.x version of the patch, too. That should be fairly easy so tagging Novice.

webchick’s picture

Title: Notice: Undefined index: » Notice: Undefined index: default_image in image_field_prepare_view()

More descriptive title.

sun’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests, -Novice

#4: drupal-1558548-4.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +Needs tests, +Novice

The last submitted patch, drupal-1558548-4.patch, failed testing.

sun’s picture

d'oh. Patch would probably also apply cleanly to D8, but alas... /core... ;)

Regarding tests: Nope, intra-D7 update tests are not supported currently. Once #1364798: Impossible to generate meaningful diffs of upgrade db dumps lands, the situation might look different, and I definitely would like to see such tests, but until then, it's not possible.

PROMES’s picture

subscribe, same error here.

Anonymous’s picture

Same issue immediately after applying D7.14

fakingfantastic’s picture

same

webchick’s picture

Status: Needs work » Fixed

Ok, I figured out I can patch -p0 the 7.x patch from the /core directory so don't need that re-roll after all.

Committed and pushed to 8.x and 7.x. Thanks!

webchick’s picture

I've also added this to the "known issues" section of the release announcement: http://drupal.org/drupal-7.14#known-issues

shaostudio’s picture

I wanted to re-size my images. I received the same error message after upgrading to Drupal 7.14 and changing the Maximum image resolution in field_image. I kinda of went around that and left the Maximum image resolution blank. I set the image size in the Image Style under Manage Display. It works for my situation but may not work for others if you require minimum and maximum resolution.

slippast’s picture

Subscribed! Thanks for looking into this problem.

Aside from a patch is there a quick fix to get around this?

BTMash’s picture

In my instance, I resaved the field settings and it was working just fine again after that.

slippast’s picture

That appeared to work for me too. Resaved the field...no warning. Thanks!

jnettik’s picture

I was getting the error in #1559696: Notice : Undefined index: default_image in image_field_update_instance() - during reconfigure but on line 505. Tried the patch in #4 and I'm not getting the error.

webchick’s picture

Updated the issue summary to point out the problem/solution to hopefully prevent more "me too" comments. Anyone please feel free to clarify it further.

pgglass’s picture

Version: 7.14 » 8.x-dev

Not sure if this means anything but I ran an update using the update script and found there were 4 updates pending. The error disappeared and seems to have fixed the problem but I incurred another problem... my "People" page disappeared. Had to revert to my backup.

StephanieFuda’s picture

Version: 8.x-dev » 7.14

Subscribe.
Same error since i upgraded yesterday.

tim.plunkett’s picture

Version: 8.x-dev » 7.x-dev
Issue tags: +Needs backport to D7

Fixing status to clarify that this is in 7.x-dev and was committed to 8.x.

frankcarey’s picture

Looks like this was fixed, but I just wanted to clarify that we are seeing this on fresh jenkins builds, not upgrades. Earlier webchick described "it only comes up on a 7.x => 7.14 upgrade". We have all our content types exported into features module, so they might have "legacy" settings now that we should upgrade and reexport?

BTMash’s picture

@frankcarey, since you are using features, it might be the case - so yes, they should get upgraded and then exported.

frankcarey’s picture

Yes, re-exporting with features adds the 'default_image' => 0, and thus should solve the issue. Others using features or defining modules in code will likely run into that as well.

Leeteq’s picture

Is @sun's comment in #5 addressed in a separate issue?

"Would probably be a good idea to open a follow-up issue to grep for all $field['settings'] and $instance['settings'] throughout core."

Christopher James Francis Rodgers’s picture

[Note aside for non-developers updating from
D7.12 to D7.14]

This error followed my update; but thee error is now gone.

I typed "update.php" without the double-quotes,
following my site's home name,
(Eg. www.my-site-example.com/update.php)
and pressed thee "Enter" key.

This runs the database updates that ought to be run
after any update to a Drupal site.

I had forgotten.

: o )

patoshi’s picture

updated core to 7.14 and received same error when going to a page with images... but after doing a cache clear it seems to have gone away.... did someone resolve it the same way? and did it come back?

webchick’s picture

Issue tags: +7.15 release notes

.

dafeder’s picture

I also got this initially but cleared the cache and it went away.

David_Rothstein’s picture

Went ahead and added this to CHANGELOG.txt now: http://drupalcode.org/project/drupal.git/commit/4f3f159

Anonymous’s picture

I question the decision to use !empty() instead of isset() for the patch? I understand the differences between empty() and isset() from the PHP perspective and for this IMO isset() should have been used.

cappersg’s picture

@ #34: Clear cache did not work for me - even after a browser restart (I'm using Google Chrome)
Tried the suggested code changes: only gets the page to crash.
For me this issue should not be tagged "fixed".......

UPDATE: when carefully running the update scripts again AFTER the suggested visit to "image field settings form" and clicking "Save" there & the clear cache it is solved for me too. It looks like the order of actions can be significant.....

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

Anonymous’s picture

Issue summary: View changes

Updating issue summary with problem/solution.