Issue status update for http://drupal.org/node/18447 Project: Drupal Version: cvs Component: system.module Category: feature requests Priority: normal Assigned to: chx Reported by: chx Updated by: mathias Status: patch This would make installing the ecommerce package easier given that modules are no longer listed alphabetically from within their subdirectories. The modules are scattered all over the page unless I adopt some sort of ec_ prefix to module naming. I wonder how Adrian's installer handles dependencies? mathias Previous comments: ------------------------------------------------------------------------ March 5, 2005 - 18:55 : chx Attachment: http://drupal.org/files/issues/depend.patch (3.22 KB) As discussed on the developer list. This was surprisingly easy. There is still an issue: t('The configuration options have been saved.') is displayed more than once if there is a dependency forced module switch on. I have tried something (you'll see) for some reason it does not work. Number of page reloads can be decreased if Drupal could be reinitialized after system_listing_save instead of redirecting but I doubt this would be feasible. Although I marked this is feature request, this is more a usability issue (for the forum-comment dependency) and as a side effect it is a useful feature, too (for any other module "bundles"). I want criticism! I'd like to get torn apart by wild animals. Heavy! Eaten by some squirrels. ------------------------------------------------------------------------ March 5, 2005 - 19:22 : clydefrog Forgive me if I'm mistaken, but shouldn't forum_depends return an array? ------------------------------------------------------------------------ March 5, 2005 - 19:26 : javanaut I think allowing for both required dependencies as well as optional ones would make it practical for a package management tool to be created. I like it, though, and I think being able to programatically enforce (or at least notify users about) dependencies would assist users who refuse to RTFM.
From my drupal-devel comment, here's how I would suggest formatting the hook_depends:
<?php function filestore2_depends() { return array('required'=>array('fscache'), 'optional'=>array('taxonomy','comments')); } ?> ------------------------------------------------------------------------ March 5, 2005 - 19:29 : chx If you take a look at module_invoke_all, you will see that a string is fine, 'cos if you return a string it does $result[] However, an associative array is not good with module_invoke_all 'cos for returned arrays there is an array_merge where "If the input arrays have the same string keys, then the later value for that key will overwrite the previous one." ------------------------------------------------------------------------ March 5, 2005 - 19:33 : javanaut Ok, how about it taking a parameter? <?php function filestore2_depends($dep_type='required') { $deps = array('required'=>array('fscache'), 'optional'=>array('taxonomy','comments')); return $deps[$dep_type]; } ?> Then, for required dependencies, pass a 'required' argument, and optional ones could take an 'optional' argument. ------------------------------------------------------------------------ March 5, 2005 - 20:00 : chx Attachment: http://drupal.org/files/issues/depend_0.patch (3.6 KB) I would leave associative arrays for the future. As we do not have a package tool, there is little use of 'optional' -- I'd like to get this into 4.6 After testing the patch, I have changed something, which I should not have done, so another version is attached. ------------------------------------------------------------------------ March 5, 2005 - 20:11 : chx Attachment: http://drupal.org/files/issues/depend_1.patch (4.37 KB) This one should really work... ------------------------------------------------------------------------ March 5, 2005 - 20:12 : chx Attachment: http://drupal.org/files/issues/depend_2.patch (3.15 KB) ------------------------------------------------------------------------ March 5, 2005 - 22:13 : gordon +1 Not only is this something that I have wanted for filestore2 for quite a while, but has not been on my priority list. But this would be extremely useful for the ecommerce modules, as there seems to be alot of interdependancy. Also on a side note, it would also be good for a module to be able to reject an enabling. So if the module is going to stop drupal from running if it does have its tables created, it will inform the user and not be turned on. This could actually be done allowing the dependancy hook to do some checking and so stop the module from being able to be enabled.