Question

I am trying to know if a user is guest using Yii::app()->user->isGuest but I get the following notice:

Undefined property: CWebApplication::$user

Apparently the component user is not yet defined in the application, I would like to know the reason.

I had tried to check if the component is avalible via

if(isset(Yii::app()->user))

However it fails ¿How can I check if the user is a guest even when Yii::app()->user is not defined?¿Should I get this notice when using isGuest?

EDIT: I changed error_reporting directive to "E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT" I needed to move forward. Now I got this fatal error:

Fatal error: Call to a member function getId() on a non-object in home/mario/projects/ciudad_wiki/yii/framework/web/auth/CWebUser.php on line 530

No Time Memory Function Location

  1. 0.0005 235120 {main}( ) ../index.php:0
  2. 0.0207 1548168 CApplication->run( ) ../index.php:13
  3. 0.0207 1548352 CWebApplication->processRequest( ) ../CApplication.php:162
  4. 0.0235 1725768 CWebApplication->runController( ) ../CWebApplication.php:135
  5. 0.0272 2103464 CController->run( ) ../CWebApplication.php:276
  6. 0.0279 2145872 CController->runActionWithFilters( ) ../CController.php:266
  7. 0.0279 2145984 CController->runAction( ) ../CController.php:287
  8. 0.0279 2146128 CInlineAction->runWithParams( ) ../CController.php:309
  9. 0.0279 2146688 SiteController->actionIndex( ) ../CInlineAction.php:50
  10. 0.0529 3875888 CController->render( ) ../SiteController.php:33
  11. 0.0529 3876112 CController->renderPartial( ) ../CController.php:783
  12. 0.0532 3877352 CBaseController->renderFile( ) ../CController.php:870
  13. 0.0532 3877672 CBaseController->renderInternal( ) ../CBaseController.php:96
  14. 0.0539 3918144 require( foo_dir/protected/views/site/index.php' ) ../CBaseController.php:127
  15. 0.0705 4428584 CModule->__get( ) ../CBaseController.php:199
  16. 0.0705 4428584 CModule->getComponent( ) ../CModule.php:104
  17. 0.0723 4580360 CWebUser->init( ) ../CModule.php:388
  18. 0.0736 4671144 CWebUser->getIsGuest( ) ../CWebUser.php:195
  19. 0.0736 4671240 CWebUser->getState( ) ../CWebUser.php:279
  20. 0.0736 4671320 CWebUser->getStateKeyPrefix( ) ../CWebUser.php:557

The trace is similar to the last one, Yii can't find anything in $_SESSION related to user component.

EDIT #2: I uploaded the trace with E_NOTICE on, here it is: PHP notice

EDIT #3: I updated php to 5.4 recently. When I run the application in a server with php 5.3 there is no problem, maybe there is a notice behind the scenes but not the fatal error I get with php 5.4. As bool.dev wrote: this is a complete guess.

Was it helpful?

Solution

Sorry, I ran a massive replacent that corrupted the framework. I realized the problem was yii directory because I don't track it with git, when I set up a new production environment, in a virtual machine, everything was fine again and the only difference was the framework directory. Thanks for you help.

OTHER TIPS

I was getting a similar problem when pulling a master branch from GitLab on a virtual machine. It looked like it couldn't find the user and/or session component.

I've been around this for days, however I found that adding this in the first line of index.php of Yii (right after "

error_reporting("E_ALL & ~E_STRICT");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top