update_resolve_dependencies($starting_updates)
Resolves dependencies in a set of module updates, and orders them correctly.
This function receives a list of requested module updates and determines an appropriate order to run them in such that all update dependencies are met. Any updates whose dependencies cannot be met are included in the returned array but have the key 'allowed' set to FALSE; the calling function should take responsibility for ensuring that these updates are ultimately not performed.
In addition, the returned array also includes detailed information about the dependency chain for each update, as provided by the depth-first search algorithm in Drupal\Component\Graph\Graph::searchAndSort().
$starting_updates: An array whose keys contain the names of modules with updates to be run and whose values contain the number of the first requested update for that module.
An array whose keys are the names of all update functions within the provided modules that would need to be run in order to fulfill the request, arranged in the order in which the update functions should be run. (This includes the provided starting update for each module and all subsequent updates that are available.) The values are themselves arrays containing all the keys provided by the Drupal\Component\Graph\Graph::searchAndSort() algorithm, which encode detailed information about the dependency chain for this update function (for example: 'paths', 'reverse_paths', 'weight', and 'component'), as well as the following additional keys:
\Drupal\Component\Graph\Graph::searchAndSort()
function update_resolve_dependencies($starting_updates) { // Obtain a dependency graph for the requested update functions. $update_functions = update_get_update_function_list($starting_updates); $graph = update_build_dependency_graph($update_functions); // Perform the depth-first search and sort on the results. $graph_object = new Graph($graph); $graph = $graph_object->searchAndSort(); uasort($graph, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement')); foreach ($graph as $function => &$data) { $module = $data['module']; $number = $data['number']; // If the update function is missing and has not yet been performed, mark // it and everything that ultimately depends on it as disallowed. if (update_is_missing($module, $number, $update_functions) && !update_already_performed($module, $number)) { $data['allowed'] = FALSE; foreach (array_keys($data['paths']) as $dependent) { $graph[$dependent]['allowed'] = FALSE; $graph[$dependent]['missing_dependencies'][] = $function; } } elseif (!isset($data['allowed'])) { $data['allowed'] = TRUE; $data['missing_dependencies'] = array(); } // Now that we have finished processing this function, remove it from the // graph if it was not part of the original list. This ensures that we // never try to run any updates that were not specifically requested. if (!isset($update_functions[$module][$number])) { unset($graph[$function]); } } return $graph; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!includes!update.inc/function/update_resolve_dependencies/8.1.x