summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2015-10-10 13:26:16 -0400
committerDavid Rothstein <drothstein@gmail.com>2015-10-10 13:26:16 -0400
commitc60d7b098a9db9abd9a8de3b6f125df3a2bfda24 (patch)
tree31e502258c9991500f338ffecfec39ad274572e4
parent56bbd4ba0165c8c8f902ee6ebde66a4d5fdfb1a0 (diff)
downloadbrdo-c60d7b098a9db9abd9a8de3b6f125df3a2bfda24.tar.gz
brdo-c60d7b098a9db9abd9a8de3b6f125df3a2bfda24.tar.bz2
Issue #2205271 by trobey, jhedstrom, hass, alexpott, chx, joachim, jhodgdon: Add an optional project namespace for dependencies
-rw-r--r--CHANGELOG.txt2
-rw-r--r--includes/common.inc25
-rw-r--r--modules/simpletest/tests/system_project_namespace_test.info7
-rw-r--r--modules/simpletest/tests/system_project_namespace_test.module1
-rw-r--r--modules/simpletest/tests/system_test.module3
-rw-r--r--modules/system/system.test12
6 files changed, 47 insertions, 3 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 4e9e4f0da..699318087 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,6 +1,8 @@
Drupal 7.40, xxxx-xx-xx (development version)
-----------------------
+- Added an optional 'project:' prefix that can be added to dependencies in a
+ module's .info file to indicate which project the dependency resides in.
- Fixed various bugs that occurred after hooks were invoked early in the Drupal
bootstrap and that caused module_implements() and drupal_alter() to cache an
incomplete set of hook implementations for later use.
diff --git a/includes/common.inc b/includes/common.inc
index ef71ee8b6..acef70afb 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -7368,7 +7368,16 @@ function drupal_write_record($table, &$record, $primary_keys = array()) {
* Information stored in a module .info file:
* - name: The real name of the module for display purposes.
* - description: A brief description of the module.
- * - dependencies: An array of shortnames of other modules this module requires.
+ * - dependencies: An array of dependency strings. Each is in the form
+ * 'project:module (versions)'; with the following meanings:
+ * - project: (optional) Project shortname, recommended to ensure uniqueness,
+ * if the module is part of a project hosted on drupal.org. If omitted,
+ * also omit the : that follows. The project name is currently ignored by
+ * Drupal core but is used for automated testing.
+ * - module: (required) Module shortname within the project.
+ * - (versions): Optional version information, consisting of one or more
+ * comma-separated operator/value pairs or simply version numbers, which
+ * can contain "x" as a wildcard. Examples: (>=7.22, <7.28), (7.x-3.x).
* - package: The name of the package of modules this module belongs to.
*
* See forum.info for an example of a module .info file.
@@ -7653,7 +7662,12 @@ 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 (>=7.x-4.5-beta5, 3.x)'.
+ * A dependency string, which specifies a module dependency, and optionally
+ * the project it comes from and versions that are supported. Supported
+ * formats include:
+ * - 'module'
+ * - 'project:module'
+ * - 'project:module (>=version, version)'
*
* @return
* An associative array with three keys:
@@ -7668,6 +7682,12 @@ function debug($data, $label = NULL, $print_r = FALSE) {
* @see drupal_check_incompatibility()
*/
function drupal_parse_dependency($dependency) {
+ $value = array();
+ // Split out the optional project name.
+ if (strpos($dependency, ':')) {
+ list($project_name, $dependency) = explode(':', $dependency);
+ $value['project'] = $project_name;
+ }
// We use named subpatterns and support every op that version_compare
// supports. Also, op is optional and defaults to equals.
$p_op = '(?P<operation>!=|==|=|<|<=|>|>=|<>)?';
@@ -7676,7 +7696,6 @@ function drupal_parse_dependency($dependency) {
$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])) {
diff --git a/modules/simpletest/tests/system_project_namespace_test.info b/modules/simpletest/tests/system_project_namespace_test.info
new file mode 100644
index 000000000..98d33afdd
--- /dev/null
+++ b/modules/simpletest/tests/system_project_namespace_test.info
@@ -0,0 +1,7 @@
+name = "System project namespace test"
+description = "Support module for testing project namespace dependencies."
+package = Testing
+version = VERSION
+core = 7.x
+hidden = TRUE
+dependencies[] = drupal:filter
diff --git a/modules/simpletest/tests/system_project_namespace_test.module b/modules/simpletest/tests/system_project_namespace_test.module
new file mode 100644
index 000000000..b3d9bbc7f
--- /dev/null
+++ b/modules/simpletest/tests/system_project_namespace_test.module
@@ -0,0 +1 @@
+<?php
diff --git a/modules/simpletest/tests/system_test.module b/modules/simpletest/tests/system_test.module
index 8c4432996..3d5a11ada 100644
--- a/modules/simpletest/tests/system_test.module
+++ b/modules/simpletest/tests/system_test.module
@@ -296,6 +296,9 @@ function system_test_system_info_alter(&$info, $file, $type) {
}
}
+ if ($file->name == 'system_project_namespace_test') {
+ $info['hidden'] = FALSE;
+ }
// Make the system_dependencies_test visible by default.
if ($file->name == 'system_dependencies_test') {
$info['hidden'] = FALSE;
diff --git a/modules/system/system.test b/modules/system/system.test
index d4c98f0a7..6e5f2b358 100644
--- a/modules/system/system.test
+++ b/modules/system/system.test
@@ -390,6 +390,18 @@ class ModuleDependencyTestCase extends ModuleTestCase {
}
/**
+ * Checks functionality of project namespaces for dependencies.
+ */
+ function testProjectNamespaceForDependencies() {
+ // Enable module with project namespace to ensure nothing breaks.
+ $edit = array(
+ 'modules[Testing][system_project_namespace_test][enable]' => TRUE,
+ );
+ $this->drupalPost('admin/modules', $edit, t('Save configuration'));
+ $this->assertModules(array('system_project_namespace_test'), TRUE);
+ }
+
+ /**
* Attempt to enable translation module without locale enabled.
*/
function testEnableWithoutDependency() {