Pretty much everything seems to assume that PHP booleans should be
converted to 0/1: MySQL does this implicitly thanks to the lack of
strict mode by default, while PostgreSQL and Sqlite (and Mssql) do it
explicitly.
The addition of MySQL strict mode for unit tests in Ib2873913 exposed
the assumption in the case of MySQL by making some extension unit tests
fail. So let's make casting bool to int the default behavior of
Database::addQuotes().
This also cleans up the phpdoc for Database::addQuotes() to properly
reflect all the supported types that can be passed to it.
Change-Id: I13d0e402fa676bc27c345e8ac12f363ebc627f6a
}
/**
- * @param string|Blob $s
- * @return string
+ * @param string|int|null|bool|Blob $s
+ * @return string|int
*/
public function addQuotes( $s ) {
if ( $s instanceof MssqlBlob ) {
}
if ( $s === null ) {
return 'NULL';
+ } elseif ( is_bool( $s ) ) {
+ return (int)$s;
} else {
# This will also quote numeric values. This should be harmless,
# and protects against weird problems that occur when they really
}
/**
- * @param null|bool|Blob $s
- * @return int|string
+ * @param string|int|null|bool|Blob $s
+ * @return string|int
*/
function addQuotes( $s ) {
if ( is_null( $s ) ) {
}
/**
- * @param Blob|string $s
- * @return string
+ * @param string|int|null|bool|Blob $s
+ * @return string|int
*/
function addQuotes( $s ) {
if ( $s instanceof Blob ) {
/**
* Adds quotes and backslashes.
*
- * @param string|Blob $s
- * @return string
+ * @param string|int|null|bool|Blob $s
+ * @return string|int
*/
public function addQuotes( $s );