summaryrefslogtreecommitdiffstats
path: root/core/includes/common.inc
diff options
context:
space:
mode:
Diffstat (limited to 'core/includes/common.inc')
-rw-r--r--core/includes/common.inc66
1 files changed, 62 insertions, 4 deletions
diff --git a/core/includes/common.inc b/core/includes/common.inc
index 0c16ac9..d97ef30 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -4839,7 +4839,7 @@ function _drupal_bootstrap_code() {
require_once DRUPAL_ROOT . '/core/includes/entity.inc';
// Load all enabled modules
- drupal_container()->get('module_handler')->loadAll();
+ module_load_all();
// Make sure all stream wrappers are registered.
file_get_stream_wrappers();
@@ -6438,7 +6438,7 @@ function drupal_flush_all_caches() {
// Ensure that all modules that are currently supposed to be enabled are
// actually loaded.
- drupal_container()->get('module_handler')->loadAll();
+ module_load_all();
// Update the list of bootstrap modules.
// Allows developers to get new hook_boot() implementations registered without
@@ -6512,10 +6512,68 @@ function debug($data, $label = NULL, $print_r = FALSE) {
}
/**
+ * Parses a dependency for comparison by drupal_check_incompatibility().
+ *
+ * @param $dependency
+ * A dependency string, for example 'foo (>=8.x-4.5-beta5, 3.x)'.
+ *
+ * @return
+ * An associative array with three keys:
+ * - 'name' includes the name of the thing to depend on (e.g. 'foo').
+ * - 'original_version' contains the original version string (which can be
+ * used in the UI for reporting incompatibilities).
+ * - 'versions' is a list of associative arrays, each containing the keys
+ * 'op' and 'version'. 'op' can be one of: '=', '==', '!=', '<>', '<',
+ * '<=', '>', or '>='. 'version' is one piece like '4.5-beta3'.
+ * Callers should pass this structure to drupal_check_incompatibility().
+ *
+ * @see drupal_check_incompatibility()
+ */
+function drupal_parse_dependency($dependency) {
+ // We use named subpatterns and support every op that version_compare
+ // supports. Also, op is optional and defaults to equals.
+ $p_op = '(?P<operation>!=|==|=|<|<=|>|>=|<>)?';
+ // Core version is always optional: 8.x-2.x and 2.x is treated the same.
+ $p_core = '(?:' . preg_quote(DRUPAL_CORE_COMPATIBILITY) . '-)?';
+ $p_major = '(?P<major>\d+)';
+ // By setting the minor version to x, branches can be matched.
+ $p_minor = '(?P<minor>(?:\d+|x)(?:-[A-Za-z]+\d+)?)';
+ $value = array();
+ $parts = explode('(', $dependency, 2);
+ $value['name'] = trim($parts[0]);
+ if (isset($parts[1])) {
+ $value['original_version'] = ' (' . $parts[1];
+ foreach (explode(',', $parts[1]) as $version) {
+ if (preg_match("/^\s*$p_op\s*$p_core$p_major\.$p_minor/", $version, $matches)) {
+ $op = !empty($matches['operation']) ? $matches['operation'] : '=';
+ if ($matches['minor'] == 'x') {
+ // Drupal considers "2.x" to mean any version that begins with
+ // "2" (e.g. 2.0, 2.9 are all "2.x"). PHP's version_compare(),
+ // on the other hand, treats "x" as a string; so to
+ // version_compare(), "2.x" is considered less than 2.0. This
+ // means that >=2.x and <2.x are handled by version_compare()
+ // as we need, but > and <= are not.
+ if ($op == '>' || $op == '<=') {
+ $matches['major']++;
+ }
+ // Equivalence can be checked by adding two restrictions.
+ if ($op == '=' || $op == '==') {
+ $value['versions'][] = array('op' => '<', 'version' => ($matches['major'] + 1) . '.x');
+ $op = '>=';
+ }
+ }
+ $value['versions'][] = array('op' => $op, 'version' => $matches['major'] . '.' . $matches['minor']);
+ }
+ }
+ }
+ return $value;
+}
+
+/**
* Checks whether a version is compatible with a given dependency.
*
* @param $v
- * A parsed dependency structure e.g. from ModuleHandler::parseDependency().
+ * The parsed dependency structure from drupal_parse_dependency().
* @param $current_version
* The version to check against (like 4.2).
*
@@ -6523,7 +6581,7 @@ function debug($data, $label = NULL, $print_r = FALSE) {
* NULL if compatible, otherwise the original dependency version string that
* caused the incompatibility.
*
- * @see \Drupal\Core\Extension\ModuleHandler::parseDependency()
+ * @see drupal_parse_dependency()
*/
function drupal_check_incompatibility($v, $current_version) {
if (!empty($v['versions'])) {