rdbms: Clean up MssqlBlob constructor
authorKunal Mehta <legoktm@member.fsf.org>
Sun, 24 Mar 2019 00:37:20 +0000 (17:37 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Fri, 5 Apr 2019 23:00:09 +0000 (16:00 -0700)
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

index 6ad934a..97d5072 100644 (file)
@@ -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 ) ) {