Permalink
Browse files

MDL-36381 cachestores: fixed bug when editing with checkbox/bool

  • Loading branch information...
Sam Hemelryk authored and stronk7 committed Nov 8, 2012
1 parent 067200e commit d837df0d776677f535afd9cbe6addd066658c200
Showing with 19 additions and 15 deletions.
  1. +7 −4 cache/stores/file/lib.php
  2. +4 −4 cache/stores/memcached/lib.php
  3. +8 −7 cache/stores/mongodb/lib.php
View
@@ -553,11 +553,14 @@ public static function config_set_edit_form_data(moodleform $editform, array $co
if (!empty($config['path'])) {
$data['path'] = $config['path'];
}
- if (!empty($config['autocreate'])) {
- $data['autocreate'] = $config['autocreate'];
+ if (isset($config['autocreate'])) {
+ $data['autocreate'] = (bool)$config['autocreate'];
}
- if (!empty($config['prescan'])) {
- $data['prescan'] = $config['prescan'];
+ if (isset($config['singledirectory'])) {
+ $data['singledirectory'] = (bool)$config['singledirectory'];
+ }
+ if (isset($config['prescan'])) {
+ $data['prescan'] = (bool)$config['prescan'];
}
$editform->set_data($data);
}
@@ -408,8 +408,8 @@ public static function config_set_edit_form_data(moodleform $editform, array $co
}
$data['servers'] = join("\n", $servers);
}
- if (!empty($config['compression'])) {
- $data['compression'] = 1;
+ if (isset($config['compression'])) {
+ $data['compression'] = (bool)$config['compression'];
}
if (!empty($config['serialiser'])) {
$data['serialiser'] = $config['serialiser'];
@@ -420,8 +420,8 @@ public static function config_set_edit_form_data(moodleform $editform, array $co
if (!empty($config['hash'])) {
$data['hash'] = $config['hash'];
}
- if (!empty($config['bufferwrites'])) {
- $data['bufferwrites'] = 1;
+ if (isset($config['bufferwrites'])) {
+ $data['bufferwrites'] = (bool)$config['bufferwrites'];
}
$editform->set_data($data);
}
@@ -419,6 +419,7 @@ public static function config_get_configuration_array($data) {
$return['usesafe'] = true;
if (!empty($data->usesafevalue)) {
$return['usesafe'] = (int)$data->usesafevalue;
+ $return['usesafevalue'] = $return['usesafe'];
}
}
return $return;
@@ -438,8 +439,8 @@ public static function config_set_edit_form_data(moodleform $editform, array $co
if (!empty($config['database'])) {
$data['database'] = $config['database'];
}
- if (!empty($config['extendedmode'])) {
- $data['extendedmode'] = 1;
+ if (isset($config['extendedmode'])) {
+ $data['extendedmode'] = (bool)$config['extendedmode'];
}
if (!empty($config['username'])) {
$data['username'] = $config['username'];
@@ -450,11 +451,11 @@ public static function config_set_edit_form_data(moodleform $editform, array $co
if (!empty($config['replicaset'])) {
$data['replicaset'] = $config['replicaset'];
}
- if (!empty($config['usesafe'])) {
- $data['usesafe'] = 1;
- if ($data['usesafe'] !== true) {
- $data['usesafevalue'] = (int)$data['usesafe'];
- }
+ if (isset($config['usesafevalue'])) {
+ $data['usesafe'] = true;
+ $data['usesafevalue'] = (int)$data['usesafe'];
+ } else if (isset($config['usesafe'])) {
+ $data['usesafe'] = (bool)$config['usesafe'];
}
$editform->set_data($data);
}

0 comments on commit d837df0

Please sign in to comment.