Closed (outdated)
Project:
Drupal core
Version:
7.x-dev
Component:
image system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
3 May 2012 at 18:00 UTC
Updated:
12 Oct 2015 at 22:05 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
webchickI believe that's the same bug. Either try the patch in #4 or update to 7.x-dev and report back!
Comment #2
wla_g commentedThe patch of #4 didn't solve the issue for me. The error message still shows up if I modify an existing image-field. I've set the status back to active.
Regards
Werner
Comment #3
ergophobe commentedI had a similar error, but for line 505, as reported in #22 of #1558548: Notice: Undefined index: default_image in image_field_prepare_view() and it was fixed by patch #4 when modifying an existing image field.
Comment #4
ergophobe commentedScratch that - still getting the same error when updating an existing image field that already has a valid default image assigned to the field, but the instance itself does not have a custom default image.
I think the reason it appeared to be solved by the other patch might be that this only occurs on the first edit after upgrading? Not sure about that.
The version I'm working on is not managed by git, but I tried changing image.module line 505 to
$fid_old = (empty($prior_instance['settings']['default_image'])) ? NULL : $prior_instance['settings']['default_image'];But I seem to be getting errors because of that
Comment #5
logicelement commented#4 works for me.
Comment #6
BDaggerhart commentedSubscribing
Comment #7
agerard commentedSubscribing - thought #4 was working, but
there are still some places/situations where the error appearsthe patch I found was not #4, and only covered the first 'empty' default (instance) not the second (field). Seems ok now.Comment #8
ankur commentedThis bug is related to #1558548: Notice: Undefined index: default_image in image_field_prepare_view(), but not the exact same bug.
Previously (prior to commit d0b5d31c for #751168: Regression: Missing "Default image" per field instance), if you created an image field with no default image, an array would get saved to the data column of {field_config_instance}, but there wouldn't be any 'default_image' key in the settings array.
So, if you created your array with a version of image.module prior to that, then updated to a version subsequent to that, you get the following snipped of code in hook_field_update_instance():
The line causing the notice is the one that reads:
$fid_old = $prior_instance['settings']['default_image'];Because 'default_image' was not set in the previous revision of the image.module code, we get the undefined index. Re-saving the settings once causes it to be set explicitly to 0 now, so the PHP notice shows only once on a re-save of an instance of an image field with no default image. It's harmless, but if it must be avoided, the attached patch may help.
The other option would be to add a database update that walks through the {field_config_instance} table and adds the explicit
'default' => 0to the field settings array, since adding theisset()check might be cluttering the code for a bug that will only happen once per field instance.Comment #9
gilzero commentedSub. I also get this error.
Comment #10
willvincent commentedThe patch from comment #4 in #1558548: Notice: Undefined index: default_image in image_field_prepare_view() fixed this issue for me.
The patch provided in comment #8 in this issue was not needed.
Comment #11
ankur commentedTo clarify to the previous commenter and others:
This bug is for a PHP notice that occurs on a different line in image.module than the lines that trigger a PHP notice in #1558548: Notice: Undefined index: default_image in image_field_prepare_view().
#1558548: Notice: Undefined index: default_image in image_field_prepare_view() is a related bug that triggers a PHP notice when you are viewing and image field.
The PHP notice reported here is triggered for image field instances when reconfiguring an image field with the most recent version of image module for field instances where the image field configuration instance was last modified/created with an older revision of the image module. The error occurs only once, when saving your changes to the an instance of an image field in this situation.
Comment #12
christopher james francis rodgers commented[Solved for me] - via update.php
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 )
Comment #13
MGParisi commentedStill Exists for Me, and I DID run update.php
Comment #14
rooby commented@MGParisi:
Does your error message have the same line number and function name as the one in the original post?
Or is it this one: #1558548: Notice: Undefined index: default_image in image_field_prepare_view()
Comment #15
MGParisi commentedI went to check but could not find the error message again:( A few weeks have passed Ive done nothing different, but its cleared up on its own?
Comment #16
rooby commentedThe error will only ever happen once per image field anyway.
Once you get the error the value is saved correctly and no error the next time.
Comment #17
yannickooThe patch in #8 solves the error. Can we set this issue to RTBC?
Comment #18
Anonymous (not verified) commentedCan someone role the patch in #8 for D8?
Changed title slightly to make it different from the previous issue so that it doesn't appear to be duplicate.
Comment #19
scotwith1t#8 didn't fix for me...sub...
Comment #20
trilok commentedi am getting notice error
Notice: Undefined index: default_image in image_field_update_instance() (line 501 of /home/content/42/8672442/html/modules/image/image.module).
Notice: Undefined index: default_image in image_field_update_instance() (line 505 of /home/content/42/8672442/html/modules/image/image.module).
Notice: Undefined index: default_image in image_field_update_instance() (line 501 of /home/content/42/8672442/html/modules/image/image.module).
Notice: Undefined index: default_image in image_field_update_instance() (line 505 of /home/content/42/8672442/html/modules/image/image.module)
please help
Comment #21
sheldonkreger commentedRunning update.php worked for my D7 site. Pretty disturbing that this showed up on my homepage after an automatic update, though.
Comment #22
ZenDoodles commentedThere are problems in comments above not related to this one, so a proper issue summary may help to clarify.
Note: This patch (rerolled from #8 above) only solves the issue caused by #751168: Regression: Missing "Default image" per field instance where an image field is stored without a default image set and so after the update to 7.13+ the default_image is missing from the saved field. This will only show up once and is resolved manually by resaving the image field. This patch just avoids needing to do that.
As ankur mentioned, we *could* add an empty default_image to all of the fields with an update, but it seems appropriate to me to fail gracefully either way.
Comment #23
socialnicheguru commentedwith modifications (i.e. remove "core" from patch") seems to work in D7.15
Comment #24
peterx commentedDrupal 7.15. I had the error in lines 501 and 505. I edited and saved every image field. That removed the line 505 error but not the line 501 error so I changed 501 the same way the #8 patch changes 505. Both errors are gone.
Comment #25
hass commented7.17 is still broken.
Comment #26
LTech commentedJust upgraded to 7.18 - error Notice: Undefined index: default_image in image_field_update_instance()
Comment #27
reg commentedThis error can happen a few lines above as well as I discovered while adding a field to a content type. This patch fixes that.
Comment #29
reg commentedOkay, #27 is for D7 which isn't going to pass. The only difference I can see in the patch is that /core/ is added into the path to the file so even though I don't have D8 I'm going to make this change manually and we'll see if it passes.
Comment #30
hass commentedComment #31
Gyver06 commented#29 patch doesn't change anything for me, issue not resolved, same error message still.
Comment #32
Anonymous (not verified) commentedDoes the hints at #1558548-37: Notice: Undefined index: default_image in image_field_prepare_view() help it any?
Comment #33
Gyver06 commentedUnfortunately,
#1558548-37: Notice: Undefined index: default_image in image_field_prepare_view()doesnt help. I tried it with no luck. SorryComment #34
sergeis commentedThe patch in #29 worked for me on 7.22 version. Thanks.
Comment #35
claudiu.cristeaAfter D8 conversion all field and instance settings are initialized before they are used. This error has gone.
I'm switching back to D7. Feel free to switch back if you get the error again in 8.
Comment #36
kopeboyI just got this error on a new site installation.
Comment #37
jamesoakleySetting this back to 7.x-dev - until this is fixed in the dev-branch, it follows that it will still be a live issue on any tagged releases (like 7.30), so leaving it on 7.x-dev is correct.
Comment #38
dcam commented@kopeboy
Can you tell us what the steps are to reproduce the error you're seeing? There's a lot of conflicting information in this issue, so that would help us solve the problem. Plus, most of these reports seem to be the result of upgrades with pre-7.14 configuration. Your issue may be completely different.
Comment #41
pwiniacki commentedConfirmed, got this error too.
Comment #42
valentine94Re-roll of last patch with a correct path.
Comment #43
bancarddata commented#42 has fixed my issue.
Comment #44
rudiedirkx commentedWorks like a charm.
Comment #45
reg commentedThat's weird. I looked at the patch in #27 and the paths are the same as #42. The starting line number is a little different but we can chalk that up the module changing a little over time and other than that the patches are identical.
The only thing I can think of as to why one worked and the other didn't is that the tester got a little smarter in the 2 years between tests.
Comment #46
David_Rothstein commented@Reg, #27 failed when the testbot tried to apply it against Drupal 8. It applies fine to Drupal 7.
I'm not really sure what's going on with this issue :) #8 and #22 have pretty good explanations for why we might want to do this in the $prior_instance case (although there's a limit to how much we should care about leftover stuff from a years-old bug causing a one-time harmless notice, I guess it's reasonable to do a quick fix here!). It would be great to have a code comment explaining that though.
However, I'm not sure I understand the second fix (the one for the $instance) - why do we need that too, and what are the exact steps to reproduce a bug with that? It seems like that one might be hiding an existing bug that should be fixed somewhere else instead...
Comment #47
reg commented@David_Rothstein: Honestly, that was so long ago I no longer remember doing it yet along why and how to comment, sorry.
I am curious though, how to do you tell the test bot to apply against D7 instead of D8?
Comment #48
David_Rothstein commentedI believe it runs based on whatever the "Version" field of the issue points to.