From b96a83b4a9a0d9fb77a4891592ea0c0a9a75ce60 Mon Sep 17 00:00:00 2001 From: Dries Date: Mon, 21 Nov 2011 22:18:43 -0500 Subject: - Patch #765860 by effulgentsia, dww, dereine, mikey_p, xjm, sun, sven.lauer: drupal_alter() fails to order modules correctly in some cases. --- modules/simpletest/tests/common_test.module | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'modules/simpletest/tests/common_test.module') diff --git a/modules/simpletest/tests/common_test.module b/modules/simpletest/tests/common_test.module index c400eaed1..e75b45237 100644 --- a/modules/simpletest/tests/common_test.module +++ b/modules/simpletest/tests/common_test.module @@ -165,6 +165,34 @@ function bartik_drupal_alter_alter(&$data, &$arg2 = NULL, &$arg3 = NULL) { } } +/** + * Implements hook_TYPE_alter() on behalf of block module. + * + * This is for verifying that drupal_alter(array(TYPE1, TYPE2), ...) allows + * hook_module_implements_alter() to affect the order in which module + * implementations are executed. + */ +function block_drupal_alter_foo_alter(&$data, &$arg2 = NULL, &$arg3 = NULL) { + $data['foo'] .= ' block'; +} + +/** + * Implements hook_module_implements_alter(). + * + * @see block_drupal_alter_foo_alter() + */ +function common_test_module_implements_alter(&$implementations, $hook) { + // For drupal_alter(array('drupal_alter', 'drupal_alter_foo'), ...), make the + // block module implementations run after all the other modules. Note that + // when drupal_alter() is called with an array of types, the first type is + // considered primary and controls the module order. + if ($hook == 'drupal_alter_alter' && isset($implementations['block'])) { + $group = $implementations['block']; + unset($implementations['block']); + $implementations['block'] = $group; + } +} + /** * Implements hook_theme(). */ -- cgit v1.2.3