From 790ac80b847ad161249508c4ed99b84f686bc4d1 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Sat, 23 Mar 2019 17:37:20 -0700 Subject: [PATCH] rdbms: Clean up MssqlBlob constructor Returning inside PHP constructors doesn't work, so whatever this code was previously trying to do didn't work. Now we directly set $this->data to the existing $data->data. Note that we can't fall through to the instanceof Blob due to MssqlBlob->fetch() not being idempotent. Also expand the @param documentation for $data. h/t to phan for highlighting this and Anomie for explaining that the behavior was wrong and how to properly fix it. Change-Id: Ied5ba2f63cbaf7c8e0f951000dbc4aa3089edd80 --- includes/libs/rdbms/encasing/MssqlBlob.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/includes/libs/rdbms/encasing/MssqlBlob.php b/includes/libs/rdbms/encasing/MssqlBlob.php index 6ad934acc4..97d5072f9f 100644 --- a/includes/libs/rdbms/encasing/MssqlBlob.php +++ b/includes/libs/rdbms/encasing/MssqlBlob.php @@ -6,12 +6,11 @@ class MssqlBlob extends Blob { /** @noinspection PhpMissingParentConstructorInspection */ /** - * @param string $data - * @suppress PhanTypeMagicVoidWithReturn + * @param Blob|array|string $data */ public function __construct( $data ) { if ( $data instanceof MssqlBlob ) { - return $data; + $this->data = $data->data; } elseif ( $data instanceof Blob ) { $this->data = $data->fetch(); } elseif ( is_array( $data ) && is_object( $data ) ) { -- 2.20.1