Quantcast
Viewing all articles
Browse latest Browse all 872

fwrite() expects parameter 2 to be string with getScreenThumbnailImage()

Hello,

 

We continue to test our application after the migration to the stable version of the sdk php (1.0.0-314767) and we got another error. This time, it is when we want to get a thumbnail Image of our vms.

 

we've got this message error :

 

fwrite() expects parameter 2 to be string, object given

 

after we looked in the code we saw that the problem come from the following functions in Http/Client.php file and in VMware_VCloud_SDK_Http_Client class:

public function download($url, $headers, $dest)
    {
        $fd = fopen($dest, 'wb');
        fwrite($fd, $this->get($url, $headers));
        fclose($fd);
    }

 

this function (like upload()) are new and were in Util.php in the beta. But in this former function the get function used was in  VMware_VCloud_SDK_Service_Abstract class and returned directly the http body in responseif reObj=false. So now the new download function return a http response object.

 

So,The problem is that $this->get($url, $headers) return an object and fwrite() function need to have a string value in place. So we resolved temporarly the problem by using the getBody() function from  VMware_VCloud_SDK_Http_Response_Interface class in Http/IResponse.php file.

 

that is our patch :

Index: Client.php
===================================================================
--- Client.php (revision 363)
+++ Client.php (working copy)
@@ -209,7 +209,7 @@
     public function download($url, $headers, $dest)
     {
         $fd = fopen($dest, 'wb');
-        fwrite($fd, $this->get($url, $headers));
+        fwrite($fd, $this->get($url, $headers)->getBody());
         fclose($fd);
     }

regards,

Yann CONAN

Viewing all articles
Browse latest Browse all 872

Trending Articles