25.4. Migrating from previous versions

While the external API of Zend_Http_Client has remained consistent throughout the 1.x branch of Zend Framework, some changes were introduced to the internal structure of Zend_Http_Client and its related classes.

These changes should have no affect on code using Zend_Http_Client - but may have an effect on PHP classes overloading or extending it. If your application subclasses Zend_Http_Client, it is highly recommended to review the following changes before upgrading Zend Framework.

25.4.1. Migrating from 1.8 or older to 1.9 or newer

25.4.1.1. Changes to internal uploaded file information storage

In version 1.9 of Zend Framework, there has been a change in the way Zend_Http_Client internally stores information about files to be uploaded, set using the Zend_Http_Client::setFileUpload() method.

This change was introduced in order to allow multiple files to be uploaded with the same form name, as an array of files. More information about this issue can be found in this bug report.

Example 25.23. Internal storage of uploaded file information

// Upload two files with the same form element name, as an array
$client = new Zend_Http_Client();
$client->setFileUpload('file1.txt',
                       'userfile[]',
                       'some raw data',
                       'text/plain');
$client->setFileUpload('file2.txt',
                       'userfile[]',
                       'some other data',
                       'application/octet-stream');

// In Zend Framework 1.8 or older, the value of
// the protected member $client->files is:
// $client->files = array(
//     'userfile[]' => array('file2.txt',
                             'application/octet-stream',
                             'some other data')
// );

// In Zend Framework 1.9 or newer, the value of $client->files is:
// $client->files = array(
//     array(
//         'formname' => 'userfile[]',
//         'filename' => 'file1.txt,
//         'ctype'    => 'text/plain',
//         'data'     => 'some raw data'
//     ),
//     array(
//         'formname' => 'userfile[]',
//         'filename' => 'file2.txt',
//         'formname' => 'application/octet-stream',
//         'formname' => 'some other data'
//     )
// );

As you can see, this change permits the usage of the same form element name with more than one file - however, it introduces a subtle backwards-compatibility change and as such should be noted.

25.4.1.2. Deprecation of Zend_Http_Client::_getParametersRecursive()

Starting from version 1.9, the protected method _getParametersRecursive() is no longer used by Zend_Http_Client and is deprecated. Using it will cause an E_NOTICE message to be emitted by PHP.

If you subclass Zend_Http_Client and call this method, you should look into using the Zend_Http_Client::_flattenParametersArray() static method instead.

Again, since this _getParametersRecursive is a protected method, this change will only affect users who subclass Zend_Http_Client.