Skip to content

Commit

Permalink
fix(config): empty string is valid for numericopt
Browse files Browse the repository at this point in the history
There was a bug that the empty string was considered to be invalid if
also a max or min value was defined for a config field of type
numericopt.
  • Loading branch information
micgro42 committed Aug 15, 2017
1 parent dd7064d commit 55a4f13
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/plugins/config/settings/config.class.php
Expand Up @@ -982,6 +982,22 @@ function out($var, $fmt='php') {
class setting_numericopt extends setting_numeric {
// just allow an empty config
var $_pattern = '/^(|[-]?[0-9]+(?:[-+*][0-9]+)*)$/';


/**
* Empty string is valid for numericopt
*
* @param mixed $input
*
* @return bool
*/
function update($input) {
if ($input === '') {
return true;
}

return parent::update($input);
}
}
}

Expand Down

1 comment on commit 55a4f13

@Chris--S
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not good. When $input is empty it doesn't attempt to update the setting value - ie. its not possible to change from actual value to an empty setting.

Please sign in to comment.