diff -rup mediawiki-1.11.0.orig/includes/Database.php mediawiki-1.11.0/includes/Database.php --- mediawiki-1.11.0.orig/includes/Database.php 2008-01-23 15:23:05.000000000 -0600 +++ mediawiki-1.11.0/includes/Database.php 2008-01-23 15:17:47.000000000 -0600 @@ -36,6 +36,22 @@ class DBObject { }; /** + * Utility class + * @addtogroup Database + * + * This allows us to distinguish a blob from a normal string and an array of strings + */ +class Blob { + var $data; + function __construct($data) { + $this->mData = $data; + } + function fetch() { + return $this->mData; + } +}; + +/** * Utility class. * @addtogroup Database */ diff -rup mediawiki-1.11.0.orig/includes/DatabasePostgres.php mediawiki-1.11.0/includes/DatabasePostgres.php --- mediawiki-1.11.0.orig/includes/DatabasePostgres.php 2008-01-23 15:21:28.000000000 -0600 +++ mediawiki-1.11.0/includes/DatabasePostgres.php 2008-01-23 15:18:07.000000000 -0600 @@ -1139,9 +1139,13 @@ END; } function encodeBlob( $b ) { - return pg_escape_bytea( $b ); + return new Blob ( pg_escape_bytea( $b ) ) ; } + function decodeBlob( $b ) { + if ($b instanceof Blob) { + $b = $b->fetch(); + } return pg_unescape_bytea( $b ); } @@ -1152,11 +1156,10 @@ END; function addQuotes( $s ) { if ( is_null( $s ) ) { return 'NULL'; - } else if (is_array( $s )) { ## Assume it is bytea data - return "E'$s[1]'"; + } else if ($s instanceof Blob) { + return "'".$s->fetch($s)."'"; } return "'" . pg_escape_string($s) . "'"; - // Unreachable: return "E'" . pg_escape_string($s) . "'"; } function quote_ident( $s ) {