Unsupported operand types when call _getAllParams()

December 31, 2006 on 2:40 pm | In Zend Framework |

I think it is a bug, however, it seems that I can’t login into Zend Framework Wiki today. Anyway, here is what I have found.

When I call _getAllParams() in FormController, like

Code (php)
  1. $this->_getAllParams();
  2.  
  3.  

I got the error message as "unsupported operand types".

Finally, I found the problem in Zend\Controller\Request\Http.php   line 601

Code (php)
  1.   590   /**
  2.   591    * Retrieve an array of parameters
  3.   592   *
  4.   593    * Retrieves a merged array of parameters, with precedence of userland
  5.   594    * params (see {@link setParam()}), $_GET, $POST (i.e., values in the
  6.   595    * userland params will take precedence over all others).
  7.   596    *
  8.   597    * @return array
  9.   598    */
  10.   599    public function getParams()
  11.   600    {
  12.   601            return $this->_params + $_GET + $_POST;
  13.   602    }
  14.  

The reason is because $_GET and/or $_POST was NULL when getParams() was called.

Temporarily , I changed it as below:

Code (php)
  1. public function getParams()
  2. {
  3.  
  4.           if ( null !== $_GET && null !== $_POST) {
  5.                  return $this->_params + $_GET + $_POST;
  6.           } elseif ( null !== $_GET && null == $_POST) {
  7.                 return $this->_params + $_GET;
  8.           } elseif ( null == $_GET && null !== $_POST) {
  9.                 return $this->_params + $_POST;
  10.           }
  11.                 return $this->_params;
  12. }

6 Comments »

RSS feed for comments on this post. TrackBack URI

  1. Hi,
    Ihave a look on your code.
    After migrate :
    I don’t have issues with post.
    I can’t get the get data and you don’t use in your code.
    Have you a example ?
    About your code.
    You could do this :

    #
    if ( null !== $_GET) {
    #
    $this->_params += $_GET ;
    }
    the same with post

    return $this->_params;

    by

    Berty

    Comment by Berty — January 2, 2007 #

  2. Thanks Berty,

    I think I did that. Could you download my source code.

    Under the root folder, open http.php, look at line 599 to 613

    Thanks.

    Jason

    Comment by admin — January 2, 2007 #

  3. Hi, Jason,

    when I try to install your code, I find the following error, will you please tell me how could I debug? thanks.

    Jeff

    Fatal error: Uncaught exception ‘Zend_Controller_Dispatcher_Exception’ with message ‘”index.php” controller does not exist’ in /homepages/21/d187987284/htdocs/zend/library/Zend.php:229 Stack trace: #0 /homepages/21/d187987284/htdocs/zend/library/Zend/Controller/Dispatcher.php(386): Zend::exception(’Zend_Controller…’, ‘”index.php” con…’) #1 /homepages/21/d187987284/htdocs/zend/library/Zend/Controller/Front.php(725): Zend_Controller_Dispatcher->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #2 /homepages/21/d187987284/htdocs/zend/index.php(55): Zend_Controller_Front->dispatch() #3 {main} thrown in /homepages/21/d187987284/htdocs/zend/library/Zend.php on line 229

    Comment by Jeff — January 4, 2007 #

  4. Jeff,

    I use Zend Studio to debug it.

    But for your case, maybe the problem is related to the configuration.

    if you debug it, please check $baseUrl after executing this statement:

    $baseUrl = substr($_SERVER[’PHP_SELF’], 0,
    strpos($_SERVER[’PHP_SELF’], ‘/index.php’));

    if $baseUrl is not what you expected. please set it manually through \application\constant.php

    Good luck!

    Jason.

    Comment by admin — January 4, 2007 #

  5. I fixed this recently in subversion. Enjoy!

    Comment by Matthew Weier O'Phinney — January 4, 2007 #

  6. Thanks Matthew,

    I saw it in revision in 2602. Your code is great!

    Comment by admin — January 4, 2007 #

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Since May 6,2007 We have Visitors
dog ramps

Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds. Valid XHTML and CSS. ^Top^