When a field_item_collection causes the file usage on the file usage page the field_item_collection title and the url are taken shown. This does not provide any logical infomation and a invalid link. When a field_item_collection causes the usage it's better to show the hostEntity information and link.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ralphvdhoudt created an issue. See original summary.

ralphvdhoudt’s picture

Version: 7.x-2.x-dev » 7.x-2.0-beta2
ralphvdhoudt’s picture

This patch changes the information on the page to the hostEntity

mvwensen’s picture

Patch works for me but because the result array is keyed with the entity id, this should be also inherited by the field_collection_items.

mvwensen’s picture

Status: Active » Needs review
paulvandenburg’s picture

Status: Needs review » Needs work

This patch has introduced a bug when you have multiple field collection usages. The $entity_type gets overwritten to the host entity_type, but for the second field collection item it still uses this overwritten entity_type that now doesn't match the entity at hand.

paulvandenburg’s picture

This patch fixes the bug mentioned above by introducing a local entity type variable that can be modified without breaking the higher scope.

paulvandenburg’s picture

Improved the patch to also support paragraphs_item entities.
Perhaps a hook to discover entities that should use their host entity should be made. For now this solves my problems.

Jérôme Dehorter’s picture

Hi,

The patch can't solve a field_collection_item on a unpublished node with workbench, workbench media & workbench moderation module.

Module version :
File Entity : 7.x-2.0-beta3
Workbench : 7.x-1.2
Workbench Media : 7.x-2.1
Workbench Modiration : 7.x-1.4

I create a patch for my client. perhaps it can help you to solve this problem. The patch add node status after the host label and change entity type to add host entity type.

Jérôme Dehorter’s picture

Category: Feature request » Bug report
Status: Needs review » Needs work
joseph.olstad’s picture

@Jérôme Dehorter,
please fix your patch.

To correctly make a patch for a contrib module you must first clone the contrib module, in this case file_entity.

git clone --branch 7.x-2.x https://git.drupal.org/project/file_entity.git
cd file_entity

then make your changes in that cloned module

create your patch from the git diff.

What you submitted in #2774369-9: Change field_collection_item on file usage page to hostEntity
is a patch for YOUR environment, apparently you've created a git repo for your whole stack (and generated a patch from it) and as a consequence your patch will not apply correctly to file_entity.

For more information:
Drupal.org - Making a patch with Git

joseph.olstad’s picture

Version: 7.x-2.0-beta3 » 7.x-2.x-dev
Status: Needs work » Needs review
joseph.olstad’s picture

I corrected comment #11
clone as follows

git clone --branch 7.x-2.x https://git.drupal.org/project/file_entity.git
cd file_entity
Jérôme Dehorter’s picture

Hi,

Sorry for that, it's my first contribution and i don't know how to contribute. I do it soon and i push my contribution.

Thx for this quick reply. I hope i can help i little.

Jérôme Dehorter’s picture

Hi,

I rework the patch like you ask me. I hope it's work now.

Status: Needs review » Needs work

The last submitted patch, 15: field-item-collection-hostentity-2774369-9.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

joseph.olstad’s picture

Status: Needs work » Needs review

Nice effort Jérôme, you'll have to try again, for now setting back to Patch 8 and needs review.

Jérôme Dehorter’s picture

Hi,

I review this quick. How can I test my patch before submit ? Can I download test scripts ?

joseph.olstad’s picture

@Jérôme, enable the 'Testing' module included with all copies of Drupal 7
then go to
/admin/config/development/testing

scroll to Fieldable Files, add a checkbox , press run test button

Status: Needs review » Needs work

The last submitted patch, 20: field-item-collection-hostentity-2774369-9.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

joseph.olstad’s picture

File entity tests might just be classified under 'Files'
not sure, maybe look for 'File Entity' or file_entity tests.

Either way, it's in there, make sure the file_entity module is enabled first ,then check.

paulvandenburg’s picture

Status: Active » Needs review

I'm setting this back to needs review. I think with #8 we can already improve this module with a better handling of file usage handling withing item collections. The remarks of Jérôme might be better suited for a follow up issue, if necessary.

We are already using this patch in production of a few dozen sites already in our DvG distribution since this patch was added: #2841653: Fix bug in file_entity file usage when the file is included in multiple field collections. Which I think proves that the patch is solid, but I'll leave it up to someone else to mark it RTBC.

joseph.olstad’s picture

cannot RTBC until the tests all pass, test case might have to be adjusted , have a look at the test results and the test that is failing.

paulvandenburg’s picture

joseph.olstad’s picture

Status: Needs review » Reviewed & tested by the community

Thanks everyone, setting this to RTBC. If this blows up, I'll call @paulvandenburg
Thanks!

joseph.olstad’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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