In some cases when updating field collections the following PHP Fatal error is logged:
[19-Feb-2013 11:53:29] PHP Fatal error: Cannot access protected property FieldCollectionItemEntity::$hostEntityId in /html/drupal/sites/all/modules/field_collection_feeds/plugins/FeedsFieldCollectionProcessor.inc on line 177
In the last two versions of module "field_collection" this property is declared as "protected" ("field_collection 7.x-1.0-beta5" and "field_collection 7.x-1.0-beta4") so direct access is wrong. There seems to be a method "hostEntityId()" which should be right for getting the entity id.
But "drupal/sites/all/modules/field_collection_feeds/plugins/FeedsFieldCollectionProcessor.inc" tries to access this protected property directly which results in the cited fatal error.
Please check lines 58, 59 and 177 which all have the wrong direct access to entity->hostEntityId.
Please fix this bug.
greetings
tvierb
Comment | File | Size | Author |
---|---|---|---|
#38 | interdiff-1921128-26-37.txt | 6.41 KB | gnucifer |
#38 | FeedsUpdateIssue-1921128-37.patch | 12.42 KB | gnucifer |
#29 | FeedsUpdateIssue-1921128-26.patch | 8.12 KB | gnucifer |
#25 | interdiff-1921128-12-25.txt | 4.9 KB | ultimateboy |
#25 | FeedsUpdateIssue-1921128-25.patch | 5.01 KB | ultimateboy |
Comments
Comment #1
tvierb CreditAttribution: tvierb commented"hostEntityId()" may be right for getting the id but changing "protected" to "public" for the write access is not a solution for the write access in line 177.
Comment #2
codesmithI did an initial import and it worked fine. Deleted the imported collections and tried it again and got this error although just on line 171.
Spent a couple of hours trying to figure it out to no avail. Tried deleting all the data related to the collection but no go. Not sure why it was able to import the first time around but now I'm at a standstill. Going to try #1063434: Add Feeds integration to FieldCollection.
Comment #3
HenrikBak CreditAttribution: HenrikBak commentedIm experiencing the exact same bug. Any update on this?
Comment #4
HenrikBak CreditAttribution: HenrikBak commentedI tried reverting to 7.x-1.0-alpha1 and everything suddenly worked fine - I was able to import my field collections. When tried the second time I got the same error message as #2 and now I can't import again. Strange.
Comment #5
HenrikBak CreditAttribution: HenrikBak commented#Deleted (Double post)
Comment #6
HenrikBak CreditAttribution: HenrikBak commentedAnother update: This issue only occurs when I use the "Update existing field collection item" setting in the Feeds Importer. When I don't use this setting everything is fine.
Comment #7
g089h515r806 CreditAttribution: g089h515r806 commentedHave you read the document. https://drupal.org/node/1831004 .
Comment #8
nightonfire CreditAttribution: nightonfire commentedI don't know what I am supposed to find in that document to fix this problem ...
Comment #9
nightonfire CreditAttribution: nightonfire commentedI have tried to use the 'setHostEntity' function in the field collection module to replace the change made to the hostEntityId property. However that can not be done after the entity was created. Does anyone with more understanding of these modules have another idea of how this problem can be solved?
Comment #10
ogggg CreditAttribution: ogggg commentedI have the same problem.
Comment #11
ashrafabedHere's a patch that should fix updating for alpha3. I got this working on my dev install and believe that I pulled all of the relevant edits into this patch.. Can someone please test the patch and confirm I didn't miss anything? It may apply to alpha2 as well, or require tweaking to work there too, let me know please.
Comment #12
ashrafabedThe previous patch may have actually broken new imports but fixed updating.. this should allow both. Please test and provide feedback.
Comment #13
ashrafabedStatus from my own use: the patch fixed updating without any issue, and importing new works but feeds will say the new ones failed. That shouldn't be too difficult to debug when I have a chance, just an FYI in case someone needs it now.
Comment #14
rinasek CreditAttribution: rinasek commentedNot working for me. On update get this error and nothing happens with field collections
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '259' for key 'PRIMARY'
Comment #15
ashrafabedI have been using the patch on alpha3 for daily imports/updates over the past few months. Are you using the alpha3 version of the module?
Can anyone test the patch on a clean install using alpha3 and let me know what results they get?
Thank you - I'll see about altering the patch to get it working on the dev version.
Comment #16
rinasek CreditAttribution: rinasek commentedI've got that error on clean install using alpha3 of FC feeds, i think it was clean as it can be.
I'll check on my side what can be done to fix this.
Comment #17
HenrikBak CreditAttribution: HenrikBak commentedI have implemented the patch from #12 and it seems to resolve the error I was having earlier when updating field collections through feeds. I will report back if any problems occur.
Btw I'm using 7.x-1.0-alpha3.
Comment #18
Renee S CreditAttribution: Renee S commentedI'm seeing the integrity constraint violation as well, but not very often -- ten times in a 2000-line import, so I'm thinking it's something to do with batch restarting. Things are importing just dandy now. Thanks so much for the patch!
eta: the symptom of the violation is that a hash isn't generated in the feeds_item table.
eta 2: aaah. I think it's because occasionally I had duplicate GUIDs. Which is pretty much what the error says on the tin.
Comment #19
Renee S CreditAttribution: Renee S commentedComment #20
amenity CreditAttribution: amenity commented#12 Resolved the error for me as well with 7.x-1.0-alpha3. Thanks!
Comment #21
artsakenos CreditAttribution: artsakenos commentedI also confirm that the patch #12 works.
As for the other comments, integrity violations are correctly reported.
Comment #22
Sebastian HagensI'm using 7.x-alpha3 and had this error also when importing field collection fields for updating/replacing existing ones:
Fatal error: Cannot access protected property FieldCollectionItemEntity::$hostEntityId in /sites/all/modules/contrib/field_collection_feeds/plugins/FeedsFieldCollectionProcessor.inc on line 183
After applying patch from #12, the error is resolved.
Comment #23
froboyOne more successful "patch from #12" user. I 'm just doing a one-time import and running "Delete Items" before my import cleared up any integrity violation errors that occurred.
Comment #24
Anonymous (not verified) CreditAttribution: Anonymous commented#12 also worked for me..
About #14 (@rinasek) I think that your setting is replace existing field collection and not update..., I encountered the same SQL error, when I noticed my setting wasn't set to update...hope it will help
Comment #25
ultimateboy CreditAttribution: ultimateboy at University of Colorado Boulder commentedUpdating priority to major as generating a fatal error during an import renders this module useless.
Changing version to 1.x-dev as the issue exists there as well. Currently alpha3 and -dev are on the same commit.
Also jumping on the band-wagon to say #12 fixes this issue. However, it introduced a number of coding standards issues. I've fixed the coding standards issues. There were also references to "und" which I replaced with the LANGUAGE_NONE constant.
The rest of the patch should be the same, so this should be an easy review given lot's of people have already confirmed #12 works. Patch and interdiff attached.
Comment #26
darksnow CreditAttribution: darksnow commentedHI. I'm getting this same problem and have found that the patch in #12 does not fix the issue.
There's a TODO at the bottom of the patch asking if the check they've added is necessary but there's no change in there to assigning to the protected property, which is what's causing the error in the first place.
I've not dug into this yet but it seems like we need a setter method for this property.
Comment #27
darksnow CreditAttribution: darksnow commentedFinally had a chance to revisit this and I retract my previous statement :)
I updated my installation to the dev version and patched using #25 and it's all working now as expected.
Thanks for all the work done to get this fixed.
Comment #28
aaronglamb CreditAttribution: aaronglamb as a volunteer commentedBoth #12 and #25 now fail to apply: "patch unexpectedly ends in the middle of line"
Patch #12 was for -alpha2, ultimateboy, you changed the branch to -dev, but is that what your patch is for? Both patches now fail on both branches.
I'll probably have to dig into this shortly, we're dead in the water here.
Comment #29
gnucifer CreditAttribution: gnucifer commentedA couple of months ago I tested out the patch in #25 but major issues with the module persisted, the code also looked weird to me in some places. I ended up with a minor refactoring that probably differs quite some bit from the original patch. Sadly I don't remember the motivation behind most of these changes, and have no time to review my own patch right now. Posting in this thread anyway in case someone else find it useful. This version seems to work pretty good, and have had no issues since.
EDIT: I seem to have removed the "identifier_field" target, and this is intentional since this target is not needed and just confusing. Use a unique (for example GUID) target instead.
Comment #30
themic8 CreditAttribution: themic8 at Trail 9 commentedI tried alpha3 and dev but no luck with these patches.
Patch 12
Does not work SQL error
Patch 25
Does not work SQL error
Patch 26
PHP Fatal error: Call to undefined method FieldCollectionItemEntity::updateHostEntity() in sites/example.com/modules/contrib/field_collection_feeds/plugins/FeedsFieldCollectionProcessor.inc on line 153, referer: http://example.local/import/g_t_importer
BTW, How did you configure the GUID or the unique field?
Comment #31
gnucifer CreditAttribution: gnucifer commented@themic8 I probably use a newer version of field_collection, perhaps even dev/HEAD. I should make sure that the patch also works for older versions, but I don't have time to fix that right now. You map GUID just as for other imports and set it as a unique target I believe.
Comment #32
themic8 CreditAttribution: themic8 at Trail 9 commentedI have Field/property name of Host entity GUID under the settings set to the title of the node.
Under the mapping: Then for GUID I have the field that would be the unique reference which is on the field collection.
Comment #33
themic8 CreditAttribution: themic8 at Trail 9 commentedI checkout dev from the repo. Applied patch 26 and now getting this message: The host entity cannot be changed.
Comment #34
themic8 CreditAttribution: themic8 at Trail 9 commentedOk still testing, but it worked.
I used patch 26, and checkout the dev versions of field_collection and field_collection_feeds from the repo.
GUID set as unique.
Comment #35
themic8 CreditAttribution: themic8 at Trail 9 commentedTested on a second environment and it checks out. Works without error.
Comment #36
fonant CreditAttribution: fonant at Fonant Ltd commented- fails with "The host entity cannot be changed."
However messages say: "Updated 2 field collection item. Failed importing 121 field collection item." which suggests that some items were updated...
Comment #37
fonant CreditAttribution: fonant at Fonant Ltd commentedAh, looks like I was missing the unique IDs for the collection items, or something. All working.
Comment #38
gnucifer CreditAttribution: gnucifer commentedI made a new version of the patch, with an added feature of using the host entity feeds item GUID as bridge between imported field collection item and host entity. So if host entities are also imported by feeds, there is no need to create a create a custom field for the relation. The UI for the settings could be improved and reworked, but don't have time for this right now. It works, and solves my needs, perhaps some one else might also find it useful.
Comment #39
nicer CreditAttribution: nicer commentedthemic8 & gnucifer - When experiencing your issues, did you have any of your field Targets set as "Used as unique" in your Target Configuration? After experiencing a similar issue it occurred to me that the Identifier Field is already being used as unique. There is then no need for setting another unique target other than your Host Entity. So far, after removing any additional and unnecessary unique settings I have not had any issues with accessing FieldCollectionItemEntity::$hostEntityId.
I'm using 7.x-1.0-alpha3 of the Field Collection Feeds module.
Comment #40
moonray CreditAttribution: moonray commentedI've tested patch #38: it works.
I agree with the change to remove the "identifier_field" target, as mentioned in comment #29. Makes much more sense. The UI as is works for me. The only possible nice-up in the UI would be to use a Select field that provides all available importers as options for the "Host entity importer id" setting, but it's not essential.
Comment #41
moonray CreditAttribution: moonray commentedUpon further testing, this patch breaks import.
Upon first run, everything looks great. The proper value are created and field collections have all the right values.
When you re-run the import afterwards (make sure you have "update existing nodes" set), the fields values are lost; some are right, some (entity reference field values in my case) are lost. Some odd stuff came up during debugging where it would use the wrong hostid, but I can't confirm that at this point.
Comment #42
moonray CreditAttribution: moonray commentedTurns out my above issue was related to an issue with GUID conflict between multiple importers.
Marking back to RTBC.
Comment #43
SpartyDan CreditAttribution: SpartyDan commentedPatch committed, Thank you.