2009年6月29日星期一

[fw-mvc] Inconsistency with Zend_Controller_Request_Http

Hello,

I've run into a consistency issue with Zend_Controller_Request_Http (ZF 1.8.4). The constructor accepts a request uri, and there's also a setRequestUri method. I assumed the following two snippets of code would produce the same results:

// This works
$request = new Zend_Controller_Request_Http('http://www.example.com/foo/bar');

// This doesn't work
$request = new Zend_Controller_Request_Http();
$request->setRequestUri('http://www.example.com/foo/bar');

Looking at the source code, the constructor for Zend_Controller_Request_Http accepts a string/Zend_Uri as its only argument, but Zend_Controller_Request_Http::setRequestUri() only accepts a string. Also, they have different implementations when a string is passed in.

The constructor passes the string to Zend_Uri::factory(), validates the URI, joins the path and query with a question mark, and then passes the resulting string to setRequestUri().

setRequestUri() simply copies the string argument to the protected property $_requestUri (after extracting the query portion, if any).

It seems to me that these two implementations should be compatible. Or better yet, the constructor should proxy directly to setRequestUri() without doing any fancy work (let setRequestUri handle that).

Am I missing something or should I submit a bug report and a patch? Thanks!

--
Hector

没有评论: