After installing flag without the Entity API module then view a node, you get:
Fatal error: Call to undefined function entity_type_supports() in sites/all/modules/contrib/flag/plugins/content_types/flag_link/flag_link.inc on line 31

Installing Entity API resolves the issue - it should probably be listed as a dependency.

Comments

zxaos’s picture

Patch attached

zxaos’s picture

Status: Active » Needs review

Oops, setting as needs review.

Status: Needs review » Needs work

The last submitted patch, flag-missing-entity-dependency-1882258-1.patch, failed testing.

joachim’s picture

entity_type_supports() is only called by our CTools plugins.

Bit annoying that nobody noticed when this was committed recently, but at any rate, we can fix this by adding a module_exists() in flag_ctools_plugin_directory(), rather than adding the dependency wholesale.

joachim’s picture

Title: Missing dependency on entity » CTools plugins depend on Entity module
fahime’s picture

Status: Needs work » Needs review
joachim’s picture

Status: Needs review » Needs work

I don't think the patch is the right approach -- see #4.

dsdeiz’s picture

Issue summary: View changes
StatusFileSize
new846 bytes

I added the module_exist() in the plugin file itself instead of what was suggested in #1882258-4: CTools plugins depend on Entity module because perhaps there might be additional content type plugins in the future that wouldn't depend on entity module.

dsdeiz’s picture

Status: Needs work » Needs review
joachim’s picture

Patch looks fine.

Though now I look at the plugin in question, I see that the only thing from Entity API that it uses is the call to entity_type_supports() in hook_PLUGIN_content_type_content_types(), which is the place where we define which entity types we're available for.

Is there a way we can do without this? Since the actual rendering doesn't need Entity API it seems a shame to remove it from sites that don't have it / force them to install it for just this one function call.

dsdeiz’s picture

Status: Needs review » Needs work

Hm, yeah. There doesn't seem to be a unified way of determining whether an entity has a view callback or not. Perhaps checking if a ENTITY_NAME_view() function exists?

joachim’s picture

> Perhaps checking if a ENTITY_NAME_view() function exists?

We'd get false negatives -- and maybe even false positives too!

> There doesn't seem to be a unified way of determining whether an entity has a view callback or not.

Indeed.

But what we could do is just offer the plugin, and the presumably the admin user knows whether their entities are viewable or not. If they're not, they're not going to be putting together a panel for that entity type anyway, surely?

dsdeiz’s picture

Status: Needs work » Needs review
StatusFileSize
new997 bytes

But what we could do is just offer the plugin, and the presumably the admin user knows whether their entities are viewable or not. If they're not, they're not going to be putting together a panel for that entity type anyway, surely?

I see. I guess if that's the case, I could simply just remove the call to entity_type_supports()? Patch attached for this.

bsandor’s picture

Hi,

Im not an expert in programming, i have some background...

What im sure of is that it took me hours and hours of work finding out what the problem was. (i installed entity api to solve my issue. I believe im not the only one with this problem. Probably many people stopped using this module after having similar issues. I believe at least on modules page should be mentioned this issue. Or an examination if entity api is installed and if not, than poviding the needed function. As im not an expert, especially not drupal expert i don't know the best solutions...

Regards

joachim’s picture

Status: Needs review » Fixed

Thanks for the patch. Committed.

git commit -m "Issue #1882258 by dsdeiz: Removed use of Entity API function in CTools content types declaration." --author="dsdeiz "

Status: Fixed » Closed (fixed)

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