diff --git a/repository/lib.php b/repository/lib.php index c3b17f24a71..ca78900ebec 100644 --- a/repository/lib.php +++ b/repository/lib.php @@ -2163,10 +2163,11 @@ abstract class repository implements cacheable_object { } /** - * Get settings for repository instance + * Get settings for repository instance. * - * @param string $config - * @return array Settings + * @param string $config a specific option to get. + * @return mixed returns an array of options. If $config is not empty, then it returns that option, + * or null if the option does not exist. */ public function get_option($config = '') { global $DB; @@ -2175,13 +2176,12 @@ abstract class repository implements cacheable_object { $entries = $DB->get_records('repository_instance_config', array('instanceid' => $this->id)); $cache->set('ops:'. $this->id, $entries); } + $ret = array(); - if (empty($entries)) { - return $ret; - } foreach($entries as $entry) { $ret[$entry->name] = $entry->value; } + if (!empty($config)) { if (isset($ret[$config])) { return $ret[$config]; diff --git a/repository/upgrade.txt b/repository/upgrade.txt index 739fa814ee6..fdaed9f9f2f 100644 --- a/repository/upgrade.txt +++ b/repository/upgrade.txt @@ -3,6 +3,11 @@ information provided here is intended especially for developers. Full details of the repository API are available on Moodle docs: http://docs.moodle.org/dev/Repository_API +=== 2.6 === + +* get_option() now always return null when the first parameter ($config) is not empty, and + no value was found for this $config. Previously this could sometimes return an empty array(). + === 2.5 === * repository::append_suffix() has been deprecated, use repository::get_unused_filename() if you need