MDL-46335 backup: fixed casting issue with setting labels
authorSam Hemelryk <sam@moodle.com>
Thu, 17 Jul 2014 00:52:18 +0000 (12:52 +1200)
committerSam Hemelryk <sam@moodle.com>
Thu, 17 Jul 2014 20:29:55 +0000 (08:29 +1200)
The issue was that clean_param took an int and returned a string
and the result was used in an exact comparison.
The type change mean the comparison failed.
The solution was to ensure the param was cast as a string.

backup/util/ui/backup_ui_setting.class.php

index 9ef5865..1712a73 100644 (file)
@@ -139,7 +139,8 @@ class base_setting_ui {
      * @param string $label
      */
     public function set_label($label) {
-        if ((string)$label === '' || $label !== clean_param($label, PARAM_TEXT)) {
+        $label = (string)$label;
+        if ($label === '' || $label !== clean_param($label, PARAM_TEXT)) {
             throw new base_setting_ui_exception('setting_invalid_ui_label');
         }
         $this->label = $label;