ZF-12219: Improvement to Zend_Controller_Request_Http::isPost()


Current function does this:

'POST' == $this->getMethod()

If setMethod('post') is used on an instance of Zend_Form then isPost() will never be true.

Updated function would look like this:

public function isPost()
    if ('POST' == strtoupper($this->getMethod())) {
        return true;

    return false;


Hi James, sorry I can not follow: why you are using a {{Zend_Controller_Request_Http}} instance in your form?

  • {{Zend_Controller_Request_Http::isPost()}} uses {{Zend_Controller_Request_Http::getMethod()}}
  • {{Zend_Controller_Request_Http::getMethod()}} uses {{Zend_Controller_Request_Http::getServer()}}

 * Retrieve a member of the $_SERVER superglobal
 * If no $key is passed, returns the entire $_SERVER array.
 * @param string $key
 * @param mixed $default Default value to use if key not found
 * @return mixed Returns null if key does not exist
public function getServer($key = null, $default = null)
    if (null === $key) {
        return $_SERVER;

    return (isset($_SERVER[$key])) ? $_SERVER[$key] : $default;

How it helps in a {{Zend_Form}} object? (?)

I think the example may be bogus ($form->setMethod('post') has no bearing on the case-sensitivity of the actual HTTP request that results from submitting the form), but combined with this comment in the PHP manual it may be worth looking at whether we should still apply the fix?

The correct HTTP method is POST in all caps which is what is tested for.