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

Invalid HTTP response code

silence

Well-known member
#1
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 occurred: Invalid 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
 

Jeremy

Well-known member
#2
The second argument to responseError is a status code. You've defined an array. Presumably, you wanted that within the XenForo_Phrase constructor.
 

silence

Well-known member
#3
The second argument to responseError is a status code. You've defined an array. Presumably, you wanted that within the XenForo_Phrase constructor.
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)));
    }
 

Jeremy

Well-known member
#8
Well for one, your $dancePeriod variable is a boolean:

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

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