summaryrefslogtreecommitdiff
path: root/includes/db/DatabasePostgres.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-06-04 07:31:04 +0200
committerPierre Schmitz <pierre@archlinux.de>2015-06-04 07:58:39 +0200
commitf6d65e533c62f6deb21342d4901ece24497b433e (patch)
treef28adf0362d14bcd448f7b65a7aaf38650f923aa /includes/db/DatabasePostgres.php
parentc27b2e832fe25651ef2410fae85b41072aae7519 (diff)
Update to MediaWiki 1.25.1
Diffstat (limited to 'includes/db/DatabasePostgres.php')
-rw-r--r--includes/db/DatabasePostgres.php23
1 files changed, 17 insertions, 6 deletions
diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php
index ce14d7a9..9287f7a6 100644
--- a/includes/db/DatabasePostgres.php
+++ b/includes/db/DatabasePostgres.php
@@ -530,10 +530,12 @@ class DatabasePostgres extends DatabaseBase {
return;
}
}
- /* Transaction stays in the ERROR state until rolledback */
+ /* Transaction stays in the ERROR state until rolled back */
if ( $this->mTrxLevel ) {
+ $ignore = $this->ignoreErrors( true );
$this->rollback( __METHOD__ );
- };
+ $this->ignoreErrors( $ignore );
+ }
parent::reportQueryError( $error, $errno, $sql, $fname, false );
}
@@ -712,7 +714,7 @@ class DatabasePostgres extends DatabaseBase {
$row = $this->fetchRow( $res );
$count = array();
if ( preg_match( '/rows=(\d+)/', $row[0], $count ) ) {
- $rows = $count[1];
+ $rows = (int)$count[1];
}
}
@@ -1495,12 +1497,14 @@ SQL;
* @return Blob
*/
function encodeBlob( $b ) {
- return new Blob( pg_escape_bytea( $this->mConn, $b ) );
+ return new PostgresBlob( pg_escape_bytea( $b ) );
}
function decodeBlob( $b ) {
- if ( $b instanceof Blob ) {
+ if ( $b instanceof PostgresBlob ) {
$b = $b->fetch();
+ } elseif ( $b instanceof Blob ) {
+ return $b->fetch();
}
return pg_unescape_bytea( $b );
@@ -1520,7 +1524,12 @@ SQL;
} elseif ( is_bool( $s ) ) {
return intval( $s );
} elseif ( $s instanceof Blob ) {
- return "'" . $s->fetch( $s ) . "'";
+ if ( $s instanceof PostgresBlob ) {
+ $s = $s->fetch();
+ } else {
+ $s = pg_escape_bytea( $this->mConn, $s->fetch() );
+ }
+ return "'$s'";
}
return "'" . pg_escape_string( $this->mConn, $s ) . "'";
@@ -1692,3 +1701,5 @@ SQL;
return wfBaseConvert( substr( sha1( $lockName ), 0, 15 ), 16, 10 );
}
} // end DatabasePostgres class
+
+class PostgresBlob extends Blob {}