Index: trunk/phase3/includes/DatabasePostgres.php |
— | — | @@ -1148,9 +1148,13 @@ |
1149 | 1149 | } |
1150 | 1150 | |
1151 | 1151 | function encodeBlob( $b ) { |
1152 | | - return pg_escape_bytea( $b ); |
| 1152 | + return new Blob ( pg_escape_bytea( $b ) ) ; |
1153 | 1153 | } |
| 1154 | + |
1154 | 1155 | function decodeBlob( $b ) { |
| 1156 | + if ($b instanceof Blob) { |
| 1157 | + $b = $b->fetch(); |
| 1158 | + } |
1155 | 1159 | return pg_unescape_bytea( $b ); |
1156 | 1160 | } |
1157 | 1161 | |
— | — | @@ -1161,11 +1165,10 @@ |
1162 | 1166 | function addQuotes( $s ) { |
1163 | 1167 | if ( is_null( $s ) ) { |
1164 | 1168 | return 'NULL'; |
1165 | | - } else if (is_array( $s )) { ## Assume it is bytea data |
1166 | | - return "E'$s[1]'"; |
| 1169 | + } else if ($s instanceof Blob) { |
| 1170 | + return "'".$s->fetch($s)."'"; |
1167 | 1171 | } |
1168 | 1172 | return "'" . pg_escape_string($s) . "'"; |
1169 | | - // Unreachable: return "E'" . pg_escape_string($s) . "'"; |
1170 | 1173 | } |
1171 | 1174 | |
1172 | 1175 | function quote_ident( $s ) { |
Index: trunk/phase3/includes/Database.php |
— | — | @@ -36,6 +36,22 @@ |
37 | 37 | }; |
38 | 38 | |
39 | 39 | /** |
| 40 | + * Utility class |
| 41 | + * @addtogroup Database |
| 42 | + * |
| 43 | + * This allows us to distinguish a blob from a normal string and an array of strings |
| 44 | + */ |
| 45 | +class Blob { |
| 46 | + var $data; |
| 47 | + function __construct($data) { |
| 48 | + $this->mData = $data; |
| 49 | + } |
| 50 | + function fetch() { |
| 51 | + return $this->mData; |
| 52 | + } |
| 53 | +}; |
| 54 | + |
| 55 | +/** |
40 | 56 | * Utility class. |
41 | 57 | * @addtogroup Database |
42 | 58 | */ |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -61,6 +61,7 @@ |
62 | 62 | * Strike the link to the redirect rather than using an asterisk in Special:Listredirects |
63 | 63 | * (bug 11355) Fix false positives in Safe Mode and other config detection |
64 | 64 | when boolean settings are disabled with 'Off' via php_admin_value/php_value |
| 65 | +* (bug 11292) Fixed unserialize errors with Postgres by creating special Blob object. |
65 | 66 | |
66 | 67 | === API changes in 1.12 === |
67 | 68 | |