1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Invalid HTTP response code

Discussion in 'XenForo Development Discussions' started by silence, Nov 10, 2013.

  1. silence

    silence Well-Known Member

    I'm just triggering an error in ControllerPublic, nothing really special, using this:
    PHP:
                //Check time interval for dancing
                
    if ($dancePeriod $model->danceFloodCheck() > 0)
                {
                    return 
    $this->responseError(new XenForo_Phrase('dance_interval_check'), array('seconds' => $dancePeriod));
                }
    And I'm getting this strange error:
    PHP:
    An exception occurredInvalid HTTP response code in /public_html/xenforo/library/Zend/Controller/Response/Abstract.php on line 286

        Zend_Controller_Response_Abstract
    ->setHttpResponseCode() in XenForo/FrontController.php at line 555
        XenForo_FrontController
    ->renderView() in XenForo/FrontController.php at line 158
        XenForo_FrontController
    ->run() in /public_html/xenforo/index.php at line 13
     
  2. Jeremy

    Jeremy XenForo Moderator Staff Member

    The second argument to responseError is a status code. You've defined an array. Presumably, you wanted that within the XenForo_Phrase constructor.
     
  3. silence

    silence Well-Known Member

    Ah got it. Well the error is gone but it's not showing the parameters right.
    Code:
    You are dancing too fast! Please wait {seconds} second(s).
    Also I was basing my original code from the XF function in XenForo_Controller:
    PHP:
        public function responseFlooding($floodSeconds)
        {
            return 
    $this->responseError(new XenForo_Phrase('must_wait_x_seconds_before_performing_this_action', array('count' => $floodSeconds)));
        }
     
  4. Jeremy

    Jeremy XenForo Moderator Staff Member

    You are using {seconds} in your phrase, but you are assigning the data to {count}.
     
  5. silence

    silence Well-Known Member

    No my second post is a snippet from XenForo_Controller class. My function that is causing this error is the first post. Sorry for the misunderstanding!
     
  6. Jeremy

    Jeremy XenForo Moderator Staff Member

    What is the actual code you are now currently using?
     
  7. silence

    silence Well-Known Member

    The first post. Or would you like me to include the entire function? It's located in ControllerPublic.
     
  8. Jeremy

    Jeremy XenForo Moderator Staff Member

    Well for one, your $dancePeriod variable is a boolean:

    PHP:
    $dancePeriod $model->danceFloodCheck() > // true || false

    $dancePeriod $model>danceFloodCheck(); // int
    if ($dancePeriod 0// true || false
     

Share This Page