Only pass strings to mysqli::real_escape_string
authorErik Bernhardson <ebernhardson@wikimedia.org>
Mon, 10 Feb 2014 19:03:10 +0000 (11:03 -0800)
committerErik Bernhardson <ebernhardson@wikimedia.org>
Mon, 10 Feb 2014 19:09:57 +0000 (11:09 -0800)
HHVM will throw a fatal error when passing integer and other non-string
values to mysqli::real_escape_string.  A bug has been filed against
hhvm as https://github.com/facebook/hhvm/issues/1782.

Change-Id: I80eccbe8d872e74b8efc9b8c8f37ebce756bdcee

includes/db/DatabaseMysqli.php

index d41f3e4..290de1f 100644 (file)
@@ -274,6 +274,10 @@ class DatabaseMysqli extends DatabaseMysqlBase {
         * @return string
         */
        protected function mysqlRealEscapeString( $s ) {
+               if ( is_integer( $s ) ) {
+                       // HHVM fatals passing numbers to real_escape_string
+                       $s = (string) $s;
+               }
                return $this->mConn->real_escape_string( $s );
        }