Skip to content

Commit ac17cc3

Browse files
committed
MDL-86655 lib: Preserve native booleans in PARAM_BOOL cleaning
Return true/false for boolean inputs instead of 0/1, keeping strict comparisons and schema validation correct.
1 parent bbf404a commit ac17cc3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

public/lib/classes/param.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,10 @@ protected function clean_param_value_sequence(mixed $param): mixed {
801801
* @return mixed
802802
*/
803803
protected function clean_param_value_bool(mixed $param): mixed {
804-
// Convert to 1 or 0.
804+
// Convert to 1 or 0 or bool.
805+
if (is_bool($param)) {
806+
return $param ? true : false;
807+
}
805808
$tempstr = strtolower((string)$param);
806809
if ($tempstr === 'on' || $tempstr === 'yes' || $tempstr === 'true') {
807810
$param = 1;

0 commit comments

Comments
 (0)