I have the issue with my app written in Yii2 2.0.47 (same in 46).
When I enable PHP 8.0 or 8.1 on the server I start getting huge amount of errors like the below one:
- [Tue Nov 29 16:21:18.880199 2022] [proxy_fcgi:error] [pid 366:tid 140086160824064] [client 87.206.124.190:0] AH01071: Got error ‘PHP message: PHP Warning: Attempt to read property “imie” on null in /home/test/ftp/management_tools/views/layouts/main.php on line 31PHP message: PHP Warning: Attempt to read property “nazwisko” on null in /home/test/ftp/management_tools/views/layouts/main.php on line 32’, referer: https://example.com/login
The expected properties are in main.php and are referred from Yii::$app->user object.
The funny thing is that main.php layout is set as default one but for login page I use different one:
public function actionLogin()
{
if (!Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
}
$model->password = '';
$this->layout = 'login';
return $this->render('login', [
'model' => $model,
]);
}
This app was written in PHP 5 but I kept upgrading it till I reached 8 Almost…
Yii was upgraded each time from very old 2.0.1 version as I remember.
Any hints?
It works perfectly fine with PHP 7.4 but my hosting company wants me to change it to 8+ which is ok.