From: Kunal Mehta Date: Sun, 24 Mar 2019 00:37:20 +0000 (-0700) Subject: rdbms: Clean up MssqlBlob constructor X-Git-Tag: 1.34.0-rc.0~2134^2 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=790ac80b847ad161249508c4ed99b84f686bc4d1;p=lhc%2Fweb%2Fwiklou.git 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 --- 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 ) ) {