It was always a problem that if foo wanted to happen after bar then it only could rely on ABC order. Now, let me introduce a simple and fast solution: directory depth. If foo wants to happen after bar, it should be installed in a subdir of bar or anywhere but deeper than bar.

As depth is an indexed column and system table is very small, the performance hit, if any, should be beyond measurable.

Comments

chx’s picture

StatusFileSize
new3.52 KB
chx’s picture

Status: Active » Needs review
StatusFileSize
new3.71 KB

Keeping up w/ HEAD.

chx’s picture

StatusFileSize
new3.55 KB
killes@www.drop.org’s picture

I think this is an evil hack that lacks transparency. If we want to be able to sort the order of invoked hooks we should do it the right way and offer sorting on some admin page.

markus_petrux’s picture

There is another thing related to the way admin/modules work, that often needs to increase the PHP memory limit. It is that all modules need to be loaded in order to get access to their hook_help, etc.

Maybe it would be nice to normalize the README.txt file provided by modules in a similar way WordPress plugins/themes work. That is, the module name, version, description, could be placed on a text file that could be loaded and parsed instead of including the PHP code itself. Then, you could also add a field to specify something like "this module should be loaded after this one, if present" or something of that sort.

I already commented something about it here (just for self reference):
http://drupal.org/node/39647#comment-58934

chx’s picture

To everyone who think this is a hack (evil or not): I would be happy to display the order on admin/modules (even with an indent) and we will be sorry if we release 4.7 without any form of ordering possibility -- there is much on hook_form_alter now so modules needs to order.

gerhard killesreiter’s picture

I we want ordering of hook invocations (and I do) we need to do it right. That is, by adding a weight for each module. I know that our weighting interface sucks, but that is unrelated and needs to be dealt with separately.

chx’s picture

StatusFileSize
new5.46 KB

So, you want this? Form API made this easy...

chx’s picture

Version: 4.6.5 » 4.7.0-beta2
chx’s picture

Title: Simple ordering of modules » Ordering of modules

Oh wait, this is not so simple any more :)

killes@www.drop.org’s picture

Title: Ordering of modules » Simple ordering of modules

Yesss.

Some remarks:

the new field is still called depth in database.*

the change in function system_modules seems not needed.

I guess we should add some help text.

chx’s picture

Title: Simple ordering of modules » Ordering of modules
StatusFileSize
new4.95 KB
chx’s picture

StatusFileSize
new4.95 KB

indexes were created on depth.

dopry’s picture

The concept is nice.
I'm using it to order things getting called via form_alter.

Drumm brought up some good points about more specific ordering systems specialized to their tasks.

It looks like you're leaving a stray asort in modules_list, which breaks the functionality of this patch altogether.

chx’s picture

StatusFileSize
new5.08 KB

Good catch.

moshe weitzman’s picture

much needed, and very drupalish. code looks good. i haven't tried it yet.

markus_petrux’s picture

Since you're now ordering by weight+filename, you may want to add filename to the new key of the system table. I believe it may save an internal SQL sort.

dries’s picture

Much needed, but do we want people to reorder modules themselves?
Do you know of any other software that lets the end user tweak stuff like this?
This is going to confuse the hell out of people, and there is no mention of it in the help text?
How do we explain this to the user?
Do we really want such a prominent GUI option for this?

markus_petrux’s picture

As en example, if you create a module that need to redefine a menu callback, then you would love this feature so you can write in the INSTALL.txt file a step such "enabling this module and change its weight so it's ordered after module xxx".

For instance, the LDAP integration module uses a mini-module named "zcallbacks" to redefine user/login.

I hope that makes sense.

chx’s picture

Now. I first created a solution without a GUI. You folks called that hackish. Now I provide one that's clean. That's too much. What I am to do? Keep the weight field and remove the weight fields? That's easy, commit without the system module hunks.

Cvbge’s picture

Now. I first created a solution without a GUI. You folks called that hackish.

Dear Chx. We called your directory solution hackish.

dries’s picture

chx: nothing to worry about. I'm just polling for opinions on the GUI changes, and will commit the proper patch accordingly.

Crell’s picture

Module order dependency should never even make it to the GUI.

If Module A requires that Module B run before it, then that is true at all times. The user shouldn't be able to change something and break that.

If Module A doesn't care when it runs with respect to Module B, then there's no reason why the user should be able to change it since it would have no effect.

Whatever the solution, it should be code-based, not UI-based. Nothing good can come of users futzing with module order.

moshe weitzman’s picture

Crell - you'd be a fan of http://drupal.org/node/5491

IMO, this isnt about dependencies. We are usually talking about reordering visible elements like a list of links or a list of fieldsets such as what appears at end of the node form

I'm fine with weight showing on admin/modules. If that seems distasteful, take chx's patch without the system.module piece and let a contrib module provide the UI.

chx’s picture

StatusFileSize
new2.81 KB

Well, I am convinced now that it is better without an UI, let the modules tinker system table themselves. Indeed, a simple module could use form_alter to add weight fields and change the #theme of the whole form.

chx’s picture

StatusFileSize
new2.62 KB
moshe weitzman’s picture

wow chx. thats a clever use of form api 9add weight fields and change $theme. i hadn't thought of that.

dopry’s picture

conditional +1
as a dev tool and a temporary thing for 4.7.

I agree with drumm's comments about more task oriented ordering in http://drupal.org/node/5491. This is a sledge hammer for situations like upload processing, where you may want things to have an effect in different order per node-type, and may cause conflicts if several nodeapi modules are written to be dependent on execution ordering.

That said, I've already found two uses for this patch...

1) ordering form creation(access the upload form to add more fields).
2) handling post processing uploads (generation of file derivatives on submit).

Its working fine... haven't found any problems yet... going live with it on a site tomorrow.

chx’s picture

Status: Needs review » Reviewed & tested by the community

Let's get this in... the use case I know of: changing the taxonomy form.

dries’s picture

Status: Reviewed & tested by the community » Needs work

Patch no longer applies. Sorry.

killes@www.drop.org’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new3.49 KB

re-rolled

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD. Thanks for the quick reroll.

chx’s picture

Category: feature » bug
Status: Fixed » Reviewed & tested by the community
StatusFileSize
new1.6 KB

Opsie I broke Drupal all over. update.php loads, bootstraps which in turn tries to enumarate modules which ORDER BY clause will die. Need to do this before the full bootstrap. Not that hard.

chx’s picture

StatusFileSize
new1.6 KB

i frogot toi rerol bfr submit

chx’s picture

StatusFileSize
new1.59 KB
chx’s picture

StatusFileSize
new1.59 KB
chx’s picture

StatusFileSize
new1.59 KB
chx’s picture

StatusFileSize
new1.64 KB
dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD. Thanks.

dries’s picture

Status: Fixed » Closed (fixed)