The generic entity processor has been moved to https://www.drupal.org/project/feeds_entity_processor.

This is a followup of #1033202: [Meta] Generic entity processor.

Adding the Generic entity processor the way we did was a mistake.

We don't have to remove the class, but we should make it abstract. We need to remove the auto-supported processors. If a module wants to provide Feeds support, it will be able to subclass FeedsEntityProcessor, and create very simple support.

The problem is that there is no way for us to generically support every type of entity and support will be a nightmare. This is becoming a huge roadblock for creating a stable release.

This is unfortunate, since we've let it sit so long. It does say EXPERIMENTAL, but I'm sure there are people using it.

Comments

twistor’s picture

Issue summary: View changes
joelpittet’s picture

Sounds fair @twistor++

megachriz’s picture

Component: Code » Generic entity processor

I was thinking of maybe make it possible to specify the processor to use for the entity in hook_entity_info(). It's already possible to define handlers for other modules there, like for Views and Features. These are added by the Entity API module, see entity/views/entity.views.inc and entity/entity.features.inc. This would at least solve the problem for having duplicate processors like there is now for user, node and taxonomy term.
I realize this would require more work and that would make a new release even further away. So maybe we should postpone defining processors in hook_entity_info() until after the next release.

Note that the FeedsEntityProcessor class includes some broken features, such as that it provides the Entity ID as unique target, but lacks code that looks up the entity ID. Filter the Feeds issue queue on component "Generic entity processor" to find all issues with the FeedsEntityProcessor class. If we leave in the class, but remove all the experimental processors, we should at least document that the class has some issues.

kreynen’s picture

I don't think altering this will be as big of a problem as you are expecting. According to https://www.drupal.org/project/usage/feeds, there are only 117 sites reporting that they are using the dev snapshot. I know that's not 100% of the usage, but it's a far cry from the 68,355 using alpha8. I know I've contributed to a few dozen of these by including the dev version of as part of Community Media Start Kit Distributions. Those sites depend on the Entity support in Feeds to import Airings and Media File Entities. Airings had its own entity processor before #1033202: [Meta] Generic entity processor and Media support still requires https://www.drupal.org/project/feeds_media_internet_files to properly map the URL. Adding Processors that extend the Entity class to these modules is easy enough. Informing users how to update the mappers using the existing parse is the bigger problem, but manageable.

robertwb’s picture

As one of the happy users of this generic entity processor I am wondering about recomendations are for subclassing the processor and advertising it to feeds. @Twistor do you have ideas about how this? @mega hriz - anyone interested in a feature request for this to organize contributions?

megachriz’s picture

Issue summary: View changes
robertwb’s picture

Honestly, I don't get the thrust of the concern. The whole idea with Entities is that they ARE generic, built from pieces that are all of a conforming type. @Twistor can you elaborate on just how this is thwarting a stable release?

IMO At the least this should be spun off as a sub module or plugin. We shouldn't just let every module do it's own support - Feeds is supposed to be generic...

twistor’s picture

@kreynen, thanks for the info, that is good to know.

@MegaChriz, the hook_entity_info() is an interesting approach. I'm not sure if it's much simpler than just declaring hook_feeds_plugins(). I'm also not sure about a one-to-one mapping from entity type to processor. I've made many custom processors over the years for entities that already had them. I guess it wouldn't necessarily rule that out though.

@robertwb, this definitely deserves an explanation.

Yes, entities are supposed to be generic, and when it comes to fields, things work fine. The problem comes when entities have custom behavior that don't apply to all entities. Taxonomy hierarchy, path aliases, menu links, etc. There's no way for Feeds to be able to support every known entity. Take this issue as an example #2359157: Flag integration: missing mappers for flagged entity and flagging user ??. The Flag module should provide Feeds support, since they know how Flag entities work.

We're not planning on removing this entirely, just removing it from the UI. There will be a simple path for module authors to provide support for Feeds.

Also, I am planning on creating a sandbox module that would be a direct upgrade path for users using the current Generic Entity Processors. It will be marked deprecated, but will provide a decent stop-gap for people in a tight spot.

robertwb’s picture

@Twistor - thanks for the response, much appreciated. I look forward to the code release with this updated framework, and you can certainly count me in on processing, and offering patches if need be. My testing of this generic support has been extensive with my own custom modules, and it has been put through it's paces, I have probably a million items imported via this with nothing more than a little Tamping here and there.

FWIW - that issue that you mentioned looks like someone has a foreign key column in their entity table that isn't an entity reference, for which I say "that's what feeds tamper is for" :) -- I actually have some of that going on in my module and it's a very effective solution. One that Drupal core should tackle, that is, it should provide foreign key interface class definitions -- or maybe it does and I don't know about it.

megachriz’s picture

StatusFileSize
new8.49 KB

@twistor
I've shortly tried out the hook_entity_info() approach (see attachment). It's not simpler then just declaring hook_feeds_plugins() but it can help reducing duplicated processors like there is now in dev for user, term and node. Modules that have their own processor for their entity declare that in hook_entity_info() and that would override the "generic" one.
I've also played with the idea of moving the generic entity processor thing to a separate project. This way Feeds can focus on other issues, which make reaching a stable release at some point more realistic.

Attached is the result of my experiment with declaring processors in hook_entity_info() and also of perhaps moving everything to a separate module. I took entity/views/entity.views.inc as an example. While experimenting I changed a few things in the entity class and processor plugin declaration to see if that would improve things for the UI and the available mapping targets. The module in the experiment - which I called entityfeeds - is not meant to be used (at least not in its current form, since it breaks with the current implementation in Feeds), it is just here for an example of how a hook_entity_info() approach would look like.

robertwb’s picture

Thanks @MegaChriz - I will give this a look.

megachriz’s picture

Status: Active » Needs review
StatusFileSize
new17.43 KB

This is not going to be popular, but here is a first step of removing the generic entity processor entirely. The patch also removes the class "FeedsEntityProcessor". I think if we would move this code to an other project, the class might as well move too. An other reason for removing the class also is because it contains some half-implemented features, such as that it provides the Entity ID as unique target, but lacks code that looks up this ID.

Let's see what breaks.

mikran’s picture

The patch also removes the class "FeedsEntityProcessor".

What happened to the idea to make it abstract?

robertwb’s picture

StatusFileSize
new81.25 KB
new52.17 KB

Based on the discussion I think that the biggest issue with the current method is UI. The "Select a Processor" dialog is hopelessly cluttered (see Image 1 below for 1/3 of the entries in one of my Drupal sites!). The example given by @Twistor in #8 is a case in point, it's a "Support Request", not a bug! We don't hold up a module release for support requests pending do we?

Proposal: Provide a single "Generic Entity Processor", with a select list in the "Processor Settings" (see image 1). No offense to the work @MegaChriz has put in on this... I just think that the baby is tossed with the bathwater here. As Drupal gets more and more ready for big (or medium) data, this need will only continue to increase. And this still could be a separate sub-module, but I don't see a reason for doing so other than to have a separate issue queue, where it would still be important to reassign issues that relate to an implementation, or re-classify them as "Support Requests".

Image 1: Proposal for what the "Processor Settings" and "Select a Processor" screens should look like.
Proposed streamlined entity processor.

Image 2: Currently what the "Processor Settings" and "Select a Processor" screens look like.

Current generic entity processor view.

megachriz’s picture

Entity processor is removed so a new release can be made earlier

I would like to keep the entity processor if possible, but I think it would take a lot of effort to fix the issues it currently has where some of them might not just be fixable.
The main reason for removing it now is that a new release of Feeds can be made. Reasoning:

  • The entity processor contains features that do not work.
  • The entity processor can't support every entity type.
  • If kept and making a new release now, I think there is a high chance of introducing backwards incompatible changes when trying to fix the biggest issues, potentially causing a lot of update issues when another next release is made.

Creating a new alpha release has more priority than keeping the entity processor, in my opinion.

Generic entity processor issues

I don't think the UI is the biggest issue, the biggest issue in my opinion is that it can't work with every entity type. An other big issue is that the implementation is only halfway done. Let me sum up the current issues with the generic entity processor.

  1. Entity types can require special handling for creation and updating

    For example, an entity can have some required values in order for creation to be successful. Default values for these required values can be provided on the processor settings page, but we can't be sure that these required values can always be set via text fields.

  2. Duplicated processors

    There are now two processors for node, user and term. A specific one and an auto-generated one. More duplicate entity processors will exists when a module provides a specific processor for their entity type.

  3. Update entity based on Entity ID does not work

    The processor provides the entity ID as unique target, but contains no code to lookup the ID.
    Issue: #2004762: Entity ID as unique target does not work.

  4. Entity types may not allow to set the entity ID directly

    The processor provides the entity ID as target, but the entity type may not allow to set this directly.

  5. The processor doesn't support entity types that don't define a bundle key

    The following fatal error occurs when trying to import entities from an entity type that doesn't have a bundle key:

    Cannot access empty property in entity/includes/entity.inc on line 48

    The user entity does not provide a bundle key, see https://api.drupal.org/api/drupal/modules%21user%21user.module/function/...
    Issue: #2248483: Experimental user entity importer fails - 'Cannot access empty property'

  6. When changing from one entity processor to another, processor configuration isn't cleared

    This will cause to have invalid processor configuration. For example, the mapping configuration will report missing targets.

  7. feed_nid shouldn't be a mapping target

    Issues: #2409739: should feed_nid be exposed as a mapping target?
    #1744516: Error: Missing configuration for parameter feed_nid.

  8. #2409717: generalized entity processor shouldn't have a 'text format' option
  9. #1916298: Entity Processor branch: Default author of entity not overidden by mapping to uid

Advantages of moving the generic entity processor to a separate project

  • There is less code to maintain for Feeds
  • Issues with the generic entity processor no longer hold up a new release
  • Feeds can more focus on it's core task
  • Less issues to deal with
  • A stable release can be made even if the generic entity processor (which then would belong to an other project) still has (major) bugs

@robertwb
I appreciate your proposal for improving the UI. This would at least fix issue #2 from above and probably also #6.

@mikran

The patch also removes the class "FeedsEntityProcessor".

What happened to the idea to make it abstract?

In my opinion, if we keep the class, the issues with this class should also be fixed (and backed up with automated tests) prior to a new release, most notably issues #3, #5 and #6 from the above list. So by removing the class a new release can be made much earlier. I also figured that if we would move the generic entity processor to a separate project, the class should move as well.

robertwb’s picture

@MegaChriz - excellent list of issues. I guess these would persist if you were to spin it off into a separate module :) That said, this provides a good hit list for whatever place this code lands. So, I have some thoughts about these, because I think some should be readily fixable, or ignorable. :

#1 - I don't think this is the feeds importers problem, but rather the user needs to make sure that they have their house in order. As for when you import any data, if it's not well formed, it will break your import. As it is, if a user adds fields to nodes and those fields are implemented in Field API, Feeds importer allows them to specify it but that doesn't mean it will import cleanly.
#3 - I always get around this with Tamper so I am unaware of the trouble. Though, i thought that this was always the case with node based feeds, that there was no lookup function, and Feeds only performed an update when the Feed in question had CREATED the node in question -- am I misunderstanding here?
#4 - Understand, this should be fairly easy to un-due using entity_info to get the entity_id field and exclude from the list of columns. This should uncover #3??
#5 - I am not sure if this is the case. I have a handful of non-bundled entities that import just fine. Is this verified? Do we have a test case other than for the User type? Perhaps it is user type specific?

kreynen’s picture

Is part of the issue that none of the current Feeds project maintainers want to support this functionality regardless of which project it is in?

twistor’s picture

@kreynen, I don't think that's the issue. It's just that solving this problem generically is very hard, and holding other things up. We're really trying to get a stable version out the door.

twistor’s picture

I've created a new project over here, https://www.drupal.org/project/feeds_entity_processor.

@MegaChriz, you have full access to the project, you're probably better off figuring out who should get commit bits.

I found a couple more things to remove. I greped the git history and node_feeds_processor_targets_alter() was added with the entity processor.

Getting ready to pull the trigger on this.

twistor’s picture

Status: Needs review » Postponed
Related issues: +#2497507: Pass plugin definition to FeedsPlugin objects.

I've been trying to get the entity processor to work in its own module. I want the module to be working before we make this commit.

I've been running into circular dependencies.

See #2497507: Pass plugin definition to FeedsPlugin objects.

twistor’s picture

Status: Postponed » Active

  • twistor committed c17412e on 7.x-2.x authored by MegaChriz
    Issue #2469219 by MegaChriz, twistor: Remove the Generic Entity...
twistor’s picture

Does someone want to make a change record?

1mundus’s picture

Hi Twistor and MegaChriz, does this change mean that multilingual support could be committed soon?

Regarding Entity processor - I have used it a few times with ECK module and it worked well. I didn't do anything fancy with it, but it did import fields properly. So if it works with ECK, that new module could be useful enough for a start.

robertwb’s picture

@twistor - thanks for the start on the separate module as well as the plans to get the separate module working before removing the feature from the release. I will begin testing this new importer asap.

megachriz’s picture

@twistor

@MegaChriz, you have full access to the project, you're probably better off figuring out who should get commit bits.

Great! :) I shall move the issues that belong to the entity processor to that queue. I'm not sure though if I'll be actively working on these soon because there is also a lot of other Feeds stuff to do:

@1mundus
The multilingual thing is surely an issue I want to look into soon. I haven't looked into it since September last year, so it can take me a few weeks to get back to it. The issue is currently blocked on #2333029: Extend mapping API to allow for defaults and multiple callbacks., but I see twistor is actively working on that. The latest patch there is quite big so it can take me a while to understand all the changes that are made in there. I also am working on the D8 versions of Feeds and Feeds Extensible Parsers (see issue list above). That might slow down testing patches from the multilingual issue for me.

1mundus’s picture

@MegaChriz

OK, thank you for the explanation and working on it.

hideaway’s picture

Our quite huge international web app suddenly having problems after this patch, since it removes generic entity processor. In our case the generic entity processor worked quite well and fit our needs, but now it's gone. Is there a quick fix for this (except freezing dev version to particular commit)?

megachriz’s picture

Issue summary: View changes

@hideaway
The generic entity processor has been moved to https://www.drupal.org/project/feeds_entity_processor.

megachriz’s picture

Status: Active » Fixed
Issue tags: -Needs change record

I've created the change record for this issue.

Changes are committed, code has moved to the new project Feeds entity processor and a change record is written. All tasks for this issue are completed!

Status: Fixed » Closed (fixed)

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