diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 8fa59ea..011d723 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -359,6 +359,36 @@ function _block_rehash($theme = NULL) { } /** + * Provides block comparison function. + * + * @param $first + * First block object to compare. + * + * @param $second + * Second block object to compare. + */ +function _block_cmp($first, $second) { + + // Compare weight first. + if ($first->weight < $second->weight) { + return -1; + } + else if ($first->weight > $second->weight) { + return 1; + } + + // Compare id in the reverse order then. + if ($first->id < $second->id) { + return 1; + } + else if ($first->id > $second->id) { + return -1; + } + + return 0; +} + +/** * Initializes blocks for enabled themes. * * @param $theme_list @@ -431,9 +461,7 @@ function block_list($region) { $blocks[$region] = array(); } - uasort($blocks[$region], function($first, $second) { - return $first->weight === $second->weight ? 0 : ($first->weight < $second->weight ? -1 : 1); - }); + uasort($blocks[$region], '_block_cmp'); return $blocks[$region]; } diff --git a/core/modules/block/lib/Drupal/block/BlockListController.php b/core/modules/block/lib/Drupal/block/BlockListController.php index 03e3462..03de10d 100644 --- a/core/modules/block/lib/Drupal/block/BlockListController.php +++ b/core/modules/block/lib/Drupal/block/BlockListController.php @@ -101,7 +101,8 @@ public function load() { // @todo Move the functionality of _block_rehash() out of the listing page. $entities = _block_rehash($this->theme); - uasort($entities, array($this->entityInfo['class'], 'sort')); + uasort($entities, '_block_cmp'); + return $entities; }