Révision 6ff32cea
Ajouté par Florent Torregrosa il y a environ 9 ans
drupal7/includes/menu.inc | ||
---|---|---|
456 | 456 |
// Rebuild if we know it's needed, or if the menu masks are missing which |
457 | 457 |
// occurs rarely, likely due to a race condition of multiple rebuilds. |
458 | 458 |
if (variable_get('menu_rebuild_needed', FALSE) || !variable_get('menu_masks', array())) { |
459 |
menu_rebuild(); |
|
459 |
if (_menu_check_rebuild()) { |
|
460 |
menu_rebuild(); |
|
461 |
} |
|
460 | 462 |
} |
461 | 463 |
$original_map = arg(NULL, $path); |
462 | 464 |
|
... | ... | |
2693 | 2695 |
drupal_static_reset('menu_link_get_preferred'); |
2694 | 2696 |
} |
2695 | 2697 |
|
2698 |
/** |
|
2699 |
* Checks whether a menu_rebuild() is necessary. |
|
2700 |
*/ |
|
2701 |
function _menu_check_rebuild() { |
|
2702 |
// To absolutely ensure that the menu rebuild is required, re-load the |
|
2703 |
// variables in case they were set by another process. |
|
2704 |
$variables = variable_initialize(); |
|
2705 |
if (empty($variables['menu_rebuild_needed']) && !empty($variables['menu_masks'])) { |
|
2706 |
unset($GLOBALS['conf']['menu_rebuild_needed']); |
|
2707 |
$GLOBALS['conf']['menu_masks'] = $variables['menu_masks']; |
|
2708 |
return FALSE; |
|
2709 |
} |
|
2710 |
return TRUE; |
|
2711 |
} |
|
2712 |
|
|
2696 | 2713 |
/** |
2697 | 2714 |
* Populates the database tables used by various menu functions. |
2698 | 2715 |
* |
... | ... | |
2713 | 2730 |
// We choose to block here since otherwise the router item may not |
2714 | 2731 |
// be available in menu_execute_active_handler() resulting in a 404. |
2715 | 2732 |
lock_wait('menu_rebuild'); |
2733 |
|
|
2734 |
if (_menu_check_rebuild()) { |
|
2735 |
// If we get here and menu_masks was not set, then it is possible a menu |
|
2736 |
// is being reloaded, or that the process rebuilding the menu was unable |
|
2737 |
// to complete successfully. A missing menu_masks variable could result |
|
2738 |
// in a 404, so re-run the function. |
|
2739 |
return menu_rebuild(); |
|
2740 |
} |
|
2716 | 2741 |
return FALSE; |
2717 | 2742 |
} |
2718 | 2743 |
|
... | ... | |
2737 | 2762 |
$transaction->rollback(); |
2738 | 2763 |
watchdog_exception('menu', $e); |
2739 | 2764 |
} |
2765 |
// Explicitly commit the transaction now; this ensures that the database |
|
2766 |
// operations during the menu rebuild are committed before the lock is made |
|
2767 |
// available again, since locks may not always reside in the same database |
|
2768 |
// connection. The lock is acquired outside of the transaction so should also |
|
2769 |
// be released outside of it. |
|
2770 |
unset($transaction); |
|
2740 | 2771 |
|
2741 | 2772 |
lock_release('menu_rebuild'); |
2742 | 2773 |
return TRUE; |
Formats disponibles : Unified diff
Update core to 7.36