You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$Model->cacheQueries is a boolean, but it is common for setting values of 1 or 0 for true and false.
Using an integer causes an exception in DboSource.php::_execute (line 458 in 2.4):
if (!$query->execute($params)) {
$params is expected to be an array. The value $param is sanitized in DboSource::fetchAll (line 655) by doing an explicit check for boolean values:
if (is_bool($params)) {
$options['cache'] = $params;
$params = array();
}
Since integers do not register as booleans, the $params parameter is left as the unsanitized value of $Model->cacheQueries (in this case an integer). See DboSource::read (line 1076 in 2.4):
I don't see why explicitly checking for booleans is a bad thing. You should use the proper types where possible. Is there a reason why you cannot use proper booleans?
Once I tracked it down I used the proper booleans. However, since the use of $model->cacheQueries is deep in the read method, I had to step through the entire read method and back trace from the exception. It was a head scratcher as to why $params had a numeric value until I noticed the is_bool check and figured out that $model->cacheQueries gets passed. It's a PDOException, which wouldn't ever lead me to believe I set $model->cacheQueries incorrectly.
Maybe an exception should be thrown in DboSource::execute if params isn't an array?
Maybe, but the parameters and properties are documented as booleans. If you have a change you think would be helpful propose it as a pull request. I am going to c!ose this as using the framework improperly will cause exceptions, and I don't think adding more squishy typing is a good solution.
$Model->cacheQueries is a boolean, but it is common for setting values of 1 or 0 for true and false.
Using an integer causes an exception in DboSource.php::_execute (line 458 in 2.4):
$params is expected to be an array. The value $param is sanitized in DboSource::fetchAll (line 655) by doing an explicit check for boolean values:
Since integers do not register as booleans, the $params parameter is left as the unsanitized value of $Model->cacheQueries (in this case an integer). See DboSource::read (line 1076 in 2.4):
The text was updated successfully, but these errors were encountered: