Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
field system
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
26 May 2011 at 10:31 UTC
Updated:
29 Jul 2014 at 19:35 UTC
Jump to comment: Most recent file
Comments
Comment #1
Luna Vulpo commentedI forgot write. This problem shows up after upgrading to 7.2
Comment #2
calculus commentedSubscribing
Comment #3
webchickWe need tests for this condition, because they should've caught this.
By attachments, do you mean filefield uploads?
Comment #4
Luna Vulpo commentedYes. I add field to standard content type "article". I set for this field "field type is file"
I comment the content of this function and this warning disappears but is is not clean solution so i submit bug report.
I thing that problem is elsewhere because is this function looks same as in D7.0
Comment #5
pmelab commentedGot the same issue. Only happens if a file field is left empty and the node is displayed in a list. Looks like the $items array is not populated with all entity-ids occuring in $entities.
Same problem with taxonomy terms.
Comment #6
olafveerman commentedSame issue here, but in my case it also happens when I have nodes of different languages in the list even if all filefields have a file.
Comment #7
plachThe attached patch should fix the issue, tests are still missing.
Comment #8
webchickThanks for getting on this so quickly, plach! :D
Comment #9
plachI should stop fixing core issues at 3:00 AM, see what happened the last time :(
Comment #10
ubersuts commentedHi, when I try a dry run of the patch, I get this:
patch -p1 --dry-run < ./tf-1169426-7.patch
patching file modules/field/field.attach.inc
Hunk #1 FAILED at 303.
Hunk #2 FAILED at 312.
Hunk #3 FAILED at 329.
Hunk #4 FAILED at 347.
any ideas what I might be doing wrong?
Comment #11
plachBe sure to checkout the latest code from the 7.x branch, this applies cleanly to 7.2 however.
Comment #12
yli_ektor commented#7: tf-1169426-7.patch queued for re-testing.
Comment #13
rodrigoaguilerasuscribe
Comment #14
lklimek commentedPatch #7 seems to fix the issue (or at least remove error messages ;) ).
Comment #15
oerjann commentedPatch #7 removed the error messages for me to :)
Comment #16
fietserwinPatch #7 solves #1164230: Invalid argument supplied for foreach() in taxonomy_field_formatter_prepare_view() line 1429 of taxonomy.module for me! Marking that one as duplicate.
Comment #17
fietserwinPerhaps using the $items from the foreach is more clear (although the PHP manual states that foreach operates on a copy, the old version seems to work anyway):
Comment #18
yareckon commentedsubscribe
Comment #19
Carlos Miranda Levy commentedPatch applied properly and errors are gone on 7.2 multisite site
Comment #20
webchickI'd like to make sure this is part of 7.3.
Any takers on writing that test?
Comment #21
plachI'll do
Comment #22
plachHere are tests. The test-only patch is supposed to fail to show that tests capture the bug.
Comment #24
webchickStop that, bot. :)
Comment #25
darq88 commentedeee...how to install this patch?
Comment #26
fietserwintake the most recent patch (not the test only one) and remove the test part out of it before applying
Comment #27
darq88 commentedsorry, I'm new to drupal could you explain it to me step by step?
thx for your replay
Comment #28
fietserwinTry http://drupal.org/node/707484
Comment #29
g4b0 commented#22 worked for me!
Comment #30
isaac.el.cec@gmail.com commented#22: tf-1169426-22.patch queued for re-testing.
Comment #31
eduardo barros commented#7: tf-1169426-7.patch queued for re-testing.
Comment #32
aspilicious commentedSub
Comment #33
jviitamaki commentedSub
Comment #34
plachOk, it seems the patch fixes the issue: a feedback from @yched and @sun would be welcome...
Comment #35
sunI'm not really sure whether we also need to stack all entities by language. For monolingual sites, this change makes no difference. But on multilingual sites, $grouped_entities will contain {fields} x {languages} "copies" of each entity. Whereas it looks like we.......
well, scratch that - the overall processing logic already exists. Looks like _field_invoke_multiple() could use some @chx magic and @sun clean-up in a follow-up issue.
Is there a reason for allowing the callbacks to change $items in $grouped_items[$field_id] by reference?
Powered by Dreditor.
Comment #36
plach@sun:
If I'm not mistaken objects are always passed by reference, so what get copied are object references not object data structures.
Well, this is only a readability improvement: the old code already lets items be passed as reference, see for instance: http://api.drupal.org/api/drupal/modules--field--field.api.php/function/....
Comment #37
sunWhile that is true, the
foreach ($items[$id] as $delta => $item) {generates a copy of &$items[$id][$delta] as $item. Only the results of the callback are put back to the &$items passed by reference, but the callback only gets the copy in $item.I'd suggest to revert that change to the foreach for now. Deciding on whether field callbacks should be allowed to manipulate $items by reference looks like a different question to me that should be discussed in a separate issue.
Comment #38
plachI cannot parse your latest comment: the current
_field_invoke_multiple()code passes$grouped_items[$field_id][$langcode]as the$itemsparameter ofhook_field_X()(multiple) implementations. Implementing hooks may decide to get a reference or a copy depending on their signature.Do you mean that the current code always passes a reference and so hooks altering for their private reasons the
$itemsarray may see their changes unintentionally propagated?Comment #39
sunah, ok, now I get it -- you also replaced $grouped_items[$field_id][$langcode] with $items in the arguments passed to the field callback.
Alright, makes sense.
Powered by Dreditor.
Comment #40
Levure commentedsubscribe
Comment #41
henwu commentedsubscribe
Comment #42
snupy commentedsubscribe
Comment #43
auris commentedsubscribe
Comment #44
mordonez commentedsubscribe
Comment #45
auris commentedUsing view's frontpage, you don't get this warnings.
Comment #46
webchickAwesome work! Thanks folks!!
Committed to 8.x and 7.x.
Comment #47
Levure commentedHello !
I have a production site impacted by this issue.
Is the patch [tf-1169426-22.patch] reliable ?
Do we have to manually apply that patch, or is there a new core release planned soon ?
Many thanks in advance for your reply ! :-)
Comment #48
plachThe patch in #22 got committed: a development snapshot is coming in 4 hours. If I understood the current plans correctly, the next stable release should be available by the end of June.
Everyone here is encouraged to test the patch by manually applying it or downloading the development snapshot, because the code in it will be part of D7.3. We have more than one week to fix possible side effects and ensure D7.3 behaves well, let's make this happen ;)
Comment #49
eduardo barros commentedpatch in #22 is working for me.
Comment #50
texis commentedpatch in #22 is working for me too :-)
Comment #51
Axl commentedSub
Comment #52
Levure commentedFor information, this patch is now included in Drupal 7.4 release.
Thanks to everybody ! :-)
Comment #54
wogelberg commentedi am running windows and cygwin doesnt work properly for me.
*pulling my hair out and crying*
cant somone upload the patched files instead of the patch.
thanks