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

Issue Type: Improvement Created: 2012-05-21T08:33:28.000+0000 Last Updated: 2012-05-31T18:39:03.000+0000 Status: Resolved Fix version(s): Reporter: James Beauchamp (jbeauchamp) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Controller

  • FixForZF1.12
  • zf-crteam-review

Related issues: Attachments:


Current function does this:

<pre class="highlight">
'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:

<pre class="highlight">
public function isPost()
    if ('POST' == strtoupper($this->getMethod())) {
        return true;

    return false;


Posted by Frank Br├╝ckner (frosch) on 2012-05-21T15:48:34.000+0000

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? (?)

Posted by Adam Lundrigan (adamlundrigan) on 2012-05-29T18:51:16.000+0000

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?

Posted by Rob Allen (rob) on 2012-05-31T18:39:02.000+0000

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

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.