0

i am using cake php 3. Some days ago I have updated php version from 5.6 to 7.1.17 . Now if there is any error happen in my apps it show An Internal Server Error Occurred". I can see error log in my error.log file like this [Error] Call to a member function user() on boolean Request URL: /robots.txt

Here is how my user() function called. It was working fine with php 5.6..

public function beforeRender(Event $event)
{
    if($this->Auth->user()){
        $this->set('loggedIn', true);
    }
    else{
        $this->set('loggedIn',false);
    }
}
Fokrule
  • 844
  • 2
  • 11
  • 30
  • Why does this happen, when you call robots.txt? Did you try to set a breakpoint and debug the beforeRender() ? – Seb Jun 04 '18 at 13:19

1 Answers1

0

This is how I solved the problem. Added this line $this->loadComponent('Auth'); in the beforeRender function. I got this solution from Fatal error: Call to a member function user() on boolean

Fokrule
  • 844
  • 2
  • 11
  • 30