sintret / yii2-chat-adminlte

yii2 chat widget widget admin lte
http://sintret.com
28 stars 29 forks source link

Header Already Sent #8

Open huhufajri opened 6 years ago

huhufajri commented 6 years ago

Hi there

i found some error when use your extensions in my new server. it told header already sent on ChatRoom.php file. I use Yii 2.0.14 ..... if ($message) { $model->message = $message; $model->userId = Yii::$app->user->id;

        if ($model->save()) {
            echo $model->data(); // this cause error
        } else {
            print_r($model->getErrors());
            exit(0);
        }
    } else {
        \echo $model->data(); //this cause error
    }

....

then i find solution in https://github.com/yiisoft/yii2/issues/15782

I try replace following code like ... if ($message) { $model->message = $message; $model->userId = Yii::$app->user->id;

        if ($model->save()) {
            \Yii::$app->response->data = $model->data(); // change
        } else {
            print_r($model->getErrors());
            exit(0);
        }
    } else {
        //echo $model->data();
        \Yii::$app->response->data = $model->data(); //change
    }

...

Thanks for your attentions.. Sorry for bad english :D

sintret commented 6 years ago

Great, I will update the extension soon.