MDL-31006 revert partially @ get_config()
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Wed, 18 Jan 2012 01:09:46 +0000 (02:09 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Wed, 18 Jan 2012 01:09:46 +0000 (02:09 +0100)
The change from null to stdClass() in get_config() was leading to:

1) unit tests not passing.
2) non-equivalent evaluation in conditions (null evals false,
   stdClassi() evals true)

lib/moodlelib.php
lib/simpletest/testfilterconfig.php

index 41ddf85..5582758 100644 (file)
@@ -1318,7 +1318,7 @@ function get_config($plugin, $name = NULL) {
         if ($localcfg) {
             return (object)$localcfg;
         } else {
-            return new stdClass();
+            return null;
         }
 
     } else {
index 63d174a..28ad2df 100644 (file)
@@ -747,7 +747,7 @@ class filter_delete_config_test extends UnitTestCaseUsingDatabase {
         $expectedconfig = new stdClass;
         $expectedconfig->configname = 'Other config value';
         $this->assertEqual($expectedconfig, get_config('filter_other'));
-        $this->assertFalse(get_config('filter_name'));
+        $this->assertNull(get_config('filter_name'));
     }
 
     public function test_filter_delete_all_for_context() {