ZF-11574: setAdapter('test') fails

Issue Type: Bug Created: 2011-07-18T19:11:01.000+0000 Last Updated: 2011-07-28T20:18:31.000+0000 Status: Open Fix version(s): Reporter: Till Klampaeckel (till) Assignee: Shahar Evron (shahar) Tags: - Zend_Http_Client

Related issues: Attachments:


I updated a project to use a more recent version of ZF and a unit test failed.

I had $client->setAdapter('test'); in it in order to use Zend_Http_Client_Adapter_Test. I'm not really sure what version it used before (it doesn't say). But it's been a long, long while since ZF was updated.

Here's a patch to correct the problem:

<pre class="highlight">
Index: Client.php
--- Client.php  (revision 35)
+++ Client.php  (working copy)
@@ -861,6 +861,9 @@
     public function setAdapter($adapter)
         if (is_string($adapter)) {
+            if (false === strpos($adapter, 'Zend_Http_Client_Adapter_', 0)) {
+                $adapter = 'Zend_Http_Client_Adapter_' . ucfirst(strtolower($adapter));
+            }
             try {
             } catch (Zend_Exception $e) {

If you need a test, let me know where to find them and I'll add a patch for that as well.



Posted by Matthew Weier O'Phinney (matthew) on 2011-07-28T20:18:31.000+0000

Convenient as this would be, what if you write a custom adapter that isn't in the "Zend_Http_Client_Adapter" vendor prefix, and pass that class name to setAdapter()? As written, the patch would still prepend that prefix, and thus try and load a non-existent class.

I think this is a situation where adding a broker would work best -- and that would need to be done in ZF2.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.