Yii Framework Forum: The Http Status Code Is Invalid: - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

The Http Status Code Is Invalid:

#1 User is offline   venuk 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 15-February 13

Posted 21 November 2013 - 04:24 AM

I am in the way to move from Yii1.X to Yii2
I have created Controller,Model and View for a table.

I can see the data in grid view and controller actions are working fine
but when I try create a new entry for the model, it is throwing the below error
on the backend it is actually creating the entry.

Below is the error details in browser:

Invalid Parameter – yii\base\InvalidParamException
The HTTP status code is invalid:
 1. in /Users/XXXX/Sites/yii-advanced/vendor/yiisoft/yii2/yii/web/Response.php at line 254
         */

    public function setStatusCode($value, $text = null)
    {
        $this->_statusCode = (int)$value;
        if ($this->getIsInvalid()) {
            throw new InvalidParamException("The HTTP status code is invalid: $value");
        }
        if ($text === null) {
            $this->statusText = isset(self::$httpStatuses[$this->_statusCode]) ? self::$httpStatuses[$this->_statusCode] : '';
        } else {
            $this->statusText = $text;

2. in /Users/XXXX/Sites/yii-advanced/vendor/yiisoft/yii2/yii/web/Response.php – yii\web\Response::setStatusCode() 


Thanks in advance.
0

#2 User is offline   ORey 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,701
  • Joined: 20-April 09
  • Location:Moscow, Russia

Posted 21 November 2013 - 07:15 AM

How does your action look like?
God is real unless declared as integer
0

#3 User is offline   venuk 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 15-February 13

Posted 21 November 2013 - 07:24 AM

Below is the action created by Yii2-gii tool

	public function actionCreate()
	{
		$model = new State;

		if ($model->load($_POST) && $model->save()) {
			return $this->redirect(['view', 'id' => $model->state_id]);
		} else {
			return $this->render('create', [
				'model' => $model,
			]);
		}
	}

0

#4 User is offline   ORey 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,701
  • Joined: 20-April 09
  • Location:Moscow, Russia

Posted 21 November 2013 - 07:30 AM

and the "view" action?..
God is real unless declared as integer
0

#5 User is offline   venuk 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 15-February 13

Posted 21 November 2013 - 07:54 AM

sorry..
View action is
	public function actionView($id)
	{
		return $this->render('view', [
			'model' => $this->findModel($id),
		]);
	}

0

#6 User is offline   ORey 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,701
  • Joined: 20-April 09
  • Location:Moscow, Russia

Posted 21 November 2013 - 08:11 AM

That's strange.
Seems like passed to setStatusCode() $value is string or empty.

Possible bug.

I think you should debug Response.php to see what is coming from outside.

The simplest way is to insert
echo 'Value = ' . $value; exit; right before $this->_statusCode = (int)$value;
and see what's the actual value of $value.

But first of all, do 'composer update' to make sure you got the latest.
God is real unless declared as integer
0

#7 User is offline   Tropi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 73
  • Joined: 30-November 11

Posted 21 November 2013 - 09:26 AM

Didn't do a lot of background checking, but might be related to a recently fixed bug: https://github.com/y...ii2/issues/1220
1

#8 User is offline   venuk 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 15-February 13

Posted 21 November 2013 - 09:27 AM

Many Thanks.

I have opened an issue at
https://github.com/y...ii2/issues/1278
0

#9 User is offline   venuk 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 15-February 13

Posted 21 November 2013 - 09:40 AM

Tropi

You are right.
It is fixed a day ago.

I have updated my composer and tested now.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users