diff options
author | Andrew Dolgov <[email protected]> | 2022-12-30 19:51:34 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2022-12-30 19:51:34 +0300 |
commit | c30b24d09f4096e612965af658540595262f6848 (patch) | |
tree | acd8db50e5f47728f20e750b69ee793770735c3c /include | |
parent | 5c0a5da88cd4ea451ea625310319f916fdba35fa (diff) |
deal with type errors in batch feed editor properly, un-deprecate PDO wrapper functions and document them for posterity
Diffstat (limited to 'include')
-rw-r--r-- | include/functions.php | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/include/functions.php b/include/functions.php index 403c96b85..0d7f8c756 100644 --- a/include/functions.php +++ b/include/functions.php @@ -357,9 +357,11 @@ return $s && ($s !== "f" && $s !== "false"); //no-op for PDO, backwards compat for legacy layer } - /** @deprecated misleading name, seems to be pointless wrapper */ + /** workaround for PDO casting all query parameters to string unless type is specified explicitly, + * which breaks booleans having false value because they become empty string literals ("") causing + * DB type mismatches and breaking SQL queries */ function bool_to_sql_bool(bool $s): int { - return $s ? 1 : 0; + return (int)$s; } function file_is_locked(string $filename): bool { @@ -411,12 +413,13 @@ } } - /** + /** checkbox-specific workaround for PDO casting all query parameters to string unless type is + * specified explicitly, which breaks booleans having false value because they become empty + * string literals ("") causing DB type mismatches and breaking SQL queries * @param mixed $val - * @deprecated misleading name, seems to be a pointless wrapper */ function checkbox_to_sql_bool($val): int { - return ($val == "on") ? 1 : 0; + return ($val === "on") ? 1 : 0; } function uniqid_short(): string { |