Merge "Split change_tag sql patch"
[lhc/web/wiklou.git] / includes / db / DatabaseMysqlBase.php
index cae133b..49579b6 100644 (file)
@@ -73,7 +73,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
                $this->installErrorHandler();
                try {
                        $this->mConn = $this->mysqlConnect( $realServer );
-               } catch (Exception $ex) {
+               } catch ( Exception $ex ) {
                        wfProfileOut( "dbconnect-$server" );
                        wfProfileOut( __METHOD__ );
                        throw $ex;
@@ -469,7 +469,9 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
         * @return string
         */
        public function addIdentifierQuotes( $s ) {
-               return "`" . $this->strencode( $s ) . "`";
+               // Characters in the range \u0001-\uFFFF are valid in a quoted identifier
+               // Remove NUL bytes and escape backticks by doubling
+               return '`' . str_replace( array( "\0", '`' ), array( '', '``' ), $s )  . '`';
        }
 
        /**
@@ -1004,7 +1006,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
  */
 class MySQLField implements Field {
        private $name, $tablename, $default, $max_length, $nullable,
-               $is_pk, $is_unique, $is_multiple, $is_key, $type;
+               $is_pk, $is_unique, $is_multiple, $is_key, $type, $binary;
 
        function __construct( $info ) {
                $this->name = $info->name;
@@ -1017,6 +1019,7 @@ class MySQLField implements Field {
                $this->is_multiple = $info->multiple_key;
                $this->is_key = ( $this->is_pk || $this->is_unique || $this->is_multiple );
                $this->type = $info->type;
+               $this->binary = isset( $info->binary ) ? $info->binary : false;
        }
 
        /**
@@ -1064,6 +1067,10 @@ class MySQLField implements Field {
        function isMultipleKey() {
                return $this->is_multiple;
        }
+
+       function isBinary() {
+               return $this->binary;
+       }
 }
 
 class MySQLMasterPos implements DBMasterPos {