Steps to reproduce: Select Rules on admin/modules and accept enabling the dependencies (Entity and Entity Metadata) on the confirmation form. You get a white screen of death and your site is completely (unrecoverable) broken.

This happens because we assume that the module dependencies are ordered correctly in system_modules_submit(), but they are not. This patch delegates dependency resolution to module_enable(). Could have a performance impact, but in the current state the dependencies are just ordered randomly wrong.

Also tested with wsclient and profile2, same wrong dependency ordering.

Originally coming from #853782: Call to undefined function entity_metadata_text_formatted_properties().

Comments

klausi’s picture

Workaround for now: Enable Entity CRUD API and Entity Metadata before you enable Rules.

rszrama’s picture

This has been affecting us w/ Commerce, too.

#906668: Installation fails when all modules are enabled at once - FieldException errors

Will give this a quick review...

rszrama’s picture

On a quick test, this does seem to resolve my problems and certainly avoids any FieldException errors. My test was fairly complex, in that I simply selected the Commerce UI modules and let the form figure out it needed to enable all the Commerce API modules, their various dependencies, and their dependencies dependencies. : P

That said, I don't know enough about the changes to that submission form from alpha7 to HEAD (i.e. where'd the rsort come from?) to say this patch doesn't break other functionality. Just a +1 on the apparent fix.

klausi’s picture

StatusFileSize
new518 bytes

Uh, this is even easier. Someone made a silly mistake by using rsort() instead of ksort() (or forgot to update the sorting function after switching module names and dependency weights).

Fixing a critical core issue by adding just one character, that would be nice :-D

catch’s picture

Issue tags: +Needs tests

It should be possible to write a test for this.

marcvangend’s picture

Klausi, just to make sure: your comment says "rsort() instead of ksort()" (reverse sort instead of key sort) but in the patch you're replacing rsort with krsort (reverse key sort). Which one is correct, the patch or the comment?

carlos8f’s picture

Status: Needs review » Reviewed & tested by the community

I introduced this bug as part of #651086: Cache clearing is an ineffective mess in module_enable() and system_modules_submit(). Certainly I meant to use krsort()! Let's write the tests in a follow-up.

carlos8f’s picture

Issue tags: +beta blocker

This is definitely a beta-blocker. Sorry about creating such a silly bug :-/

sun’s picture

Status: Reviewed & tested by the community » Needs work

Sorry, but we need to add tests to make sure we don't break this again.

carlos8f’s picture

Assigned: Unassigned » carlos8f

Working on tests.

carlos8f’s picture

Status: Needs work » Needs review
StatusFileSize
new3.09 KB

Tests inspired by #652394: Aggressive watchdog message assertion. We can see if the enable order is correct by examining the watchdog table.

carlos8f’s picture

Showing that the fix works, one patch contains the krsort() + tests and the other is just tests.

Status: Needs review » Needs work

The last submitted patch, 931190-12-module-enable-order-TESTS-ONLY.patch, failed testing.

chx’s picture

there is a resetAll method in simpletest to be used after module enabling.

carlos8f’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new3.08 KB

Now we use $this->resetAll() (it was nice to learn about that!) plus I've fixed a slight inaccuracy by ordering {watchdog} by wid instead of timestamp (since timestamp will probably be the same for these entries), and a slight typo (module_test has creates module_test creates). With this we should be good-to-go.

chx’s picture

Status: Needs review » Reviewed & tested by the community

That's one fine test.

Anonymous’s picture

Status: Reviewed & tested by the community » Needs review

nice work.

nitpick that i'm ok with leaving as is if i'm the only one who cares - can we implement hook_modules_enabled() in the test module, and check the order there? that feels a bit simpler and cleaner than querying and checking watchdog entries.

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

didn't mean to change the status, cross posted with chx. i'm happy for this to go in as is.

in case people don't like my suggestion, here's the idea behind it - as it is, the test relies on watchdog module and certain configuration, but doesn't explicitly enable the module or set up that config. like many other tests, it relies on the "hey, we have standard profile bloat, so this will work", which will make it harder to port to the testing profile later.

carlos8f’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new3.31 KB
new2.64 KB

@justinrandell fair enough :P Here we go again with parallel testing so we can see that the fix/test works.

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

awesome, thanks carlos8f, RTBC.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Exxxxxxxcellent.

Great work, folks! Committed to HEAD. :)

Status: Fixed » Closed (fixed)
Issue tags: -beta blocker

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