summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-08-05 16:16:41 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-08-05 16:16:41 +0000
commite758e30450ca661f2e99f2795441b9ebe7d3c0f1 (patch)
tree81325a1340db1a2c9a31ef9173a1f10e6cc7f9c7 /includes
parent691693304b0ccafda3c2002452a8b8b8afe729f3 (diff)
downloadbrdo-e758e30450ca661f2e99f2795441b9ebe7d3c0f1.tar.gz
brdo-e758e30450ca661f2e99f2795441b9ebe7d3c0f1.tar.bz2
#533584 by chx, dww, and Nick Lewis: Allow version-level dependency support to work with beta, rc, etc.
Diffstat (limited to 'includes')
-rw-r--r--includes/module.inc19
1 files changed, 8 insertions, 11 deletions
diff --git a/includes/module.inc b/includes/module.inc
index 8fd4273ef..ffdb4c165 100644
--- a/includes/module.inc
+++ b/includes/module.inc
@@ -102,7 +102,7 @@ function _module_build_dependencies($files) {
$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)';
+ $p_minor = '(?P<minor>(?:\d+|x)(?:-[A-Za-z]+\d+)?)';
foreach ($files as $filename => $file) {
$graph[$file->name]['edges'] = array();
if (isset($file->info['dependencies']) && is_array($file->info['dependencies'])) {
@@ -116,17 +116,14 @@ function _module_build_dependencies($files) {
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') {
- // If a module is newer than 2.x then it's at least 3.0.
- $matches['minor'] = 0;
- if ($op == '>') {
+ // 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']++;
- $op = '>=';
- }
- // If a module is older or equivalent than 2.x then it is older
- // than 3.0.
- if ($op == '<=') {
- $matches['major']++;
- $op = '<';
}
// Equivalence is checked by preg.
if ($op == '=' || $op == '==') {