r26040 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r26039‎ | r26040 | r26041 >
Date:19:54, 23 September 2007
Author:greg
Status:old
Tags:
Comment:
Fix bug 11292, unserialize errors with Postgres, by changing from array to object when slinging around blobs.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Database.php (modified) (history)
  • /trunk/phase3/includes/DatabasePostgres.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/DatabasePostgres.php
@@ -1148,9 +1148,13 @@
11491149 }
11501150
11511151 function encodeBlob( $b ) {
1152 - return pg_escape_bytea( $b );
 1152+ return new Blob ( pg_escape_bytea( $b ) ) ;
11531153 }
 1154+
11541155 function decodeBlob( $b ) {
 1156+ if ($b instanceof Blob) {
 1157+ $b = $b->fetch();
 1158+ }
11551159 return pg_unescape_bytea( $b );
11561160 }
11571161
@@ -1161,11 +1165,10 @@
11621166 function addQuotes( $s ) {
11631167 if ( is_null( $s ) ) {
11641168 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)."'";
11671171 }
11681172 return "'" . pg_escape_string($s) . "'";
1169 - // Unreachable: return "E'" . pg_escape_string($s) . "'";
11701173 }
11711174
11721175 function quote_ident( $s ) {
Index: trunk/phase3/includes/Database.php
@@ -36,6 +36,22 @@
3737 };
3838
3939 /**
 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+/**
4056 * Utility class.
4157 * @addtogroup Database
4258 */
Index: trunk/phase3/RELEASE-NOTES
@@ -61,6 +61,7 @@
6262 * Strike the link to the redirect rather than using an asterisk in Special:Listredirects
6363 * (bug 11355) Fix false positives in Safe Mode and other config detection
6464 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.
6566
6667 === API changes in 1.12 ===
6768

Follow-up revisions

RevisionCommit summaryAuthorDate
r26135Merged revisions 26012-26133 via svnmerge from...david21:15, 25 September 2007

Status & tagging log