summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-11-11 00:48:56 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-11-11 00:48:56 +0000
commit28f8c5e8621591025d82dc0c894b14f957e481f9 (patch)
treea522edf52d61f1ea328e1ebdbb349659c878659b
parentf546cfa1e832487f85f5f42532087cd206c55c7f (diff)
downloadbrdo-28f8c5e8621591025d82dc0c894b14f957e481f9.tar.gz
brdo-28f8c5e8621591025d82dc0c894b14f957e481f9.tar.bz2
#424372 by mr.baileys: Fix ':: in .info files causes fatal error' bug.
-rw-r--r--includes/common.inc5
-rw-r--r--modules/simpletest/tests/common.test23
-rw-r--r--modules/simpletest/tests/common_test_info.txt10
3 files changed, 36 insertions, 2 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 6bce4c599..4f19a63b5 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -5944,6 +5944,7 @@ function drupal_parse_info_file($filename) {
*/
function drupal_parse_info_format($data) {
$info = array();
+ $constants = get_defined_constants();
if (preg_match_all('
@^\s* # Start at the beginning of a line, ignoring leading whitespace
@@ -5982,8 +5983,8 @@ function drupal_parse_info_format($data) {
$parent = &$parent[$key];
}
- // Handle PHP constants
- if (defined($value)) {
+ // Handle PHP constants.
+ if (isset($constants[$value])) {
$value = constant($value);
}
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test
index f1bd54ac1..e74b053d1 100644
--- a/modules/simpletest/tests/common.test
+++ b/modules/simpletest/tests/common.test
@@ -1576,6 +1576,29 @@ class DrupalErrorCollectionUnitTest extends DrupalWebTestCase {
}
/**
+ * Test the drupal_parse_info_file() API function.
+ */
+class ParseInfoFilesTestCase extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Parsing .info files',
+ 'description' => 'Tests parsing .info files.',
+ 'group' => 'System',
+ );
+ }
+
+ /**
+ * Parse an example .info file an verify the results.
+ */
+ function testParseInfoFile() {
+ $info_values = drupal_parse_info_file(drupal_get_path('module', 'simpletest') . '/tests/common_test_info.txt');
+ $this->assertEqual($info_values['simple_string'], 'A simple string', t('Simple string value was parsed correctly.'), t('System'));
+ $this->assertEqual($info_values['simple_constant'], WATCHDOG_INFO, t('Constant value was parsed correctly.'), t('System'));
+ $this->assertEqual($info_values['double_colon'], 'dummyClassName::', t('Value containing double-colon was parsed correctly.'), t('System'));
+ }
+}
+
+/**
* Tests for the format_date() function.
*/
class FormatDateUnitTest extends DrupalWebTestCase {
diff --git a/modules/simpletest/tests/common_test_info.txt b/modules/simpletest/tests/common_test_info.txt
new file mode 100644
index 000000000..5dff07dd1
--- /dev/null
+++ b/modules/simpletest/tests/common_test_info.txt
@@ -0,0 +1,10 @@
+; $Id$
+; Test parsing with a simple string.
+simple_string = A simple string
+
+; Test that constants can be used as values.
+simple_constant = WATCHDOG_INFO
+
+; After parsing the .info file, 'double_colon' should hold the literal value.
+; Parsing should not throw a fatal error or try to access a class constant.
+double_colon = dummyClassName::