diff -u b/core/includes/common.inc b/core/includes/common.inc --- b/core/includes/common.inc +++ b/core/includes/common.inc @@ -7289,17 +7289,31 @@ } /** - * Flushes and resets all caches, and rebuilds data structures. + * Flushes all persistent caches, resets all variables, and rebuilds all data structures. * - * At times, it is necessary to "re-initialize" the entire system to account for + * At times, it is necessary to re-initialize the entire system to account for * changed or new code. This function: - * - Clears all persistent caches (invoking hook_cache_flush()). - * - Clears all static caches. - * - Clears asset file caches. - * - Updates the system with latest extension information. - * - Rebuilds and synchronizes data structures (invoking hook_rebuild()). + * - Clears all persistent caches (invoking hook_cache_flush()), which always + * includes: + * - The bootstrap cache bin containing base system, module system, and theme + * system information. + * - The common 'cache' cache bin containing arbitrary caches. + * - The page cache. + * - The URL alias path cache. + * - Resets all static variables that have been defined via drupal_static(). + * - Clears asset (JS/CSS) file caches. + * - Updates the system with latest information about extensions (modules and + * themes). + * - Updates the bootstrap flag for modules implementing bootstrap_hooks(). + * - Rebuilds the full database schema information (invoking hook_schema()). + * - Rebuilds data structures of all modules (invoking hook_rebuild()). * - Rebuilds the menu router. * + * This means the entire system is reset to be effectively empty. After that is + * guaranteed, information about the currently active code is updated, and + * rebuild operations are successively called in order to synchronize the active + * system according to the current information defined in code. + * * All modules need to ensure that all of their caches are flushed when * hook_cache_flush() is invoked; any previously known information must no * longer exist. All following hook_rebuild() operations must be based on fresh @@ -7322,7 +7336,7 @@ */ function drupal_flush_all_caches() { // Flush all persistent caches. - // This is executed based on "previously" known information, which is + // This is executed based on old/previously known information, which is // sufficient, since new extensions cannot have any primed caches yet. foreach (module_invoke_all('cache_flush') as $bin) { cache($bin)->flush(); @@ -7361,9 +7375,6 @@ // Rebuild all information based on new module data. module_invoke_all('rebuild'); - // Synchronize to catch any actions that were added or removed. - actions_synchronize(); - // Rebuild the menu router based on all rebuilt data. // Important: This rebuild must happen last, so the menu router is guaranteed // to be based on up to date information. diff -u b/core/modules/system/system.api.php b/core/modules/system/system.api.php --- b/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -2125,6 +2125,11 @@ * system is known to return current information, so your module can safely rely * on all available data to rebuild its own. * + * The menu router is the only exception regarding rebuilt data; it is only + * rebuilt after all hook_rebuild() implementations have been invoked. That + * ensures that hook_menu() implementations and the final router rebuild can + * rely on all data being returned by all modules. + * * @see hook_cache_flush() * @see drupal_flush_all_caches() */ diff -u b/core/modules/system/system.module b/core/modules/system/system.module --- b/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -3101,6 +3101,8 @@ function system_rebuild() { // Rebuild list of date formats. system_date_formats_rebuild(); + // Synchronize any actions that were added or removed. + actions_synchronize(); } /**