Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Installation requirements checks to see if you have one of the two modules that are needed to use entity connect. The problem is that it uses the module_exists() function and the module exists function only returns TRUE if the module that you are looking for is available and enabled. Before installation this cannot ever be true. It is better to use drupal_system_listing to check the file structure to see if the modules are available. You can then later check to see if on runtime the modules are enabled.
Problem: http://cl.ly/image/0f1G1i2u1r42
Patch attached.
Comments
Comment #1
sherakama CreditAttribution: sherakama commentedComment #2
sherakama CreditAttribution: sherakama commentedre-roll with better paths.
Comment #3
jygastaud CreditAttribution: jygastaud commentedComment #4
klonosThis is indeed a tricky one: you don't want to set either of the supported modules as a dependency in the .info file because then you'd require both of them to be installed and enabled, but you don't want to not declare any dependencies because out of the box the module does not do anything on its own (unless #2116161: Support taxonomy term reference field is fixed of course and then it will work with core taxonomy fields).
Anyways, I gave the patch a quick spin at simplytest.me:
http://simplytest.me/project/entityconnect/7.x-1.x?patch[]=https://drupal.org/files/entityconnect.install.requirements_2.patch
...but it didn't work as I expected it to. I thought it was supposed to stop the module from being enabled or at least throw a warning that you need to download any of the supported modules.
Comment #5
ndewhurstI ran into this problem as well when attempting to include entityconnect in an installation profile. It seems that we ought to check to see what type of installation is occurring, and then perform the requirements checks accordingly. I created the attached patch, and it seems to work nicely in both contexts according to my testing (I attempted installation with and without one of the required modules in both cases). During a Drupal install, it checks for module existence using sherakama's method. During a manual/individual/"normal" module install, it checks using the original method. Now that this distinction is in place, it seems we should use REQUIREMENT_ERROR instead of REQUIREMENT_WARNING, in order to prevent normal installation of the module if none of the required modules are enabled.
Comment #6
klonosI'm currently giving #5 a go and will report back soon. In the meantime, I think it's worth to mention the Module Supports project:
I think we should support this and start using either
supports[] = modulename
orenhances[] = modulename
in this module's .info file. So we should either add this:...or this (I actually believe this is a better fit in our case):
Comment #7
jygastaud CreditAttribution: jygastaud commentedThanks @ndewhurst for the patch. I will try to review it soon.
You mentionned "sherakama's method", can you provide me a link?
Also, is there any limitation (OS compatibility?) with the use of drupal_system_listing()?
@klonos, thanks for pointing supports module but if I can avoid depencies like that it looks to be better for me.
Comment #8
ndewhurstHi jygastaud,
By "sherakama's method" I meant using drupal_system_listing() as shown in comment #2 above. That approach makes sense to me, for cases when module_exists() will always return FALSE. drupal_system_listing() seems to be OS agnostic; using it along with DRUPAL_PHP_FUNCTION_PATTERN seems to be a proven approach (e.g. in bootstrap.inc:drupal_get_filename()).
I just updated my patch to use drupal_installation_attempted() to determine whether we're in a Drupal install context.
Comment #9
jygastaud CreditAttribution: jygastaud commentedThanks for patch update.
It looks great.
I will give it a try in on a fresh installation and if everything OK I will push it in 7.x-1.x branch.
Comment #11
jygastaud CreditAttribution: jygastaud commentedThanks everyone for the help.