1 system.module system_redirect_deprecated_page($path, $argument_map = array())

Menu callback; Redirects a deprecated menu location to a new path.

This wrapper around backdrop_goto_deprecated() should be used as the menu callback in hook_menu() when redirecting from an old path to a new one.

@since 1.19.0 Function added.


string $path: The path to which the user should be redirected. Because this is intended to be used as a page callback, the old path is pulled from the current menu location (the $_GET['q'] variable).

array $argument_map: If the old path and new path have differing argument orders, this can be used to map an argument from one position to another. An old path of "my-module/%key-one/edit/%" could be redirected to "my-module/configure/%key-one/%" by setting a map such as:

     1 => 2
     3 => 3

Note that this map is zero-indexed.

See also



core/modules/system/system.module, line 4348
Configuration system that lets administrators modify the workings of the site.


function system_redirect_deprecated_page($path, $argument_map = array()) {
  // The argument map is passed in as old => new. But we need to get the old
  // keys based on the new position in $path. So flip to make retrieving easy.
  $argument_map = array_flip($argument_map);

  // Perform any substitutions in the passed-in path with the current path.
  $parts = explode('/', $path);
  foreach ($parts as $index => $path_part) {
    if (backdrop_substr($path_part, 0, 1) === '%') {
      if (!empty($argument_map)) {
        $parts[$index] = arg($argument_map[$index]);
      else {
        $parts[$index] = arg($index);
  $path = implode('/', $parts);