EBernhardson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/170396
Change subject: Always decode Blob objects from Database::decodeBlob
......................................................................
Always decode Blob objects from Database::decodeBlob
The current API for Database::encodeBlob/Database::decodeBlob requires the
code that is outputing binary data to have a database handle, so that it
may call Database::encodeBlob to get either a plain string or a Blob object
back.
This is a rather inconvenient API, it tightly couples the creation of binary
data with the Database object unnecessarily. If all database objects accept
a Blob via Database::decodeBlob() then code can simply wrap it's arguments in
Blob and know that any database it ends up at will be properly handled.
This patch changes the default implementation of Database::decodeBlob
to recognize a Blob object was passed in, and use Blob::fetch to turn
it back into a string.
Bug: 72367
Change-Id: I12fb4bd339be19137fffba2e47a70741382f6a8c
---
M includes/db/Database.php
M includes/db/DatabaseMysqlBase.php
2 files changed, 6 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/96/170396/1
diff --git a/includes/db/Database.php b/includes/db/Database.php
index 4bb646e..c3b1501 100644
--- a/includes/db/Database.php
+++ b/includes/db/Database.php
@@ -3864,6 +3864,9 @@
* @return string
*/
public function decodeBlob( $b ) {
+ if ( $b instanceof Blob ) {
+ $b = $b->fetch();
+ }
return $b;
}
diff --git a/includes/db/DatabaseMysqlBase.php
b/includes/db/DatabaseMysqlBase.php
index 2008f4d..68fc2be 100644
--- a/includes/db/DatabaseMysqlBase.php
+++ b/includes/db/DatabaseMysqlBase.php
@@ -532,6 +532,9 @@
* @return string
*/
function strencode( $s ) {
+ if ( $s instanceof Blob ) {
+ $s = $s->fetch();
+ }
$sQuoted = $this->mysqlRealEscapeString( $s );
if ( $sQuoted === false ) {
--
To view, visit https://gerrit.wikimedia.org/r/170396
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I12fb4bd339be19137fffba2e47a70741382f6a8c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits