I'm getting the error "Trying to get property of non-object" when attempting to call an array using php object syntax.
Yii::log(print_r($terminalReport->terminal->started_at,true));
That line will actually log the started_at time correctly and then error out.
This code works on a production server. However, this is not working on a recently set up dev environment.
Is there a PHP module I'm missing that will allow me to call an array using that syntax without throwing an error?
Here is the full stack trace:
2015/08/25 13:22:12 [error] [php] Trying to get property of non-object (/PATH/app/protected/models/TerminalReportManager.php:33)
Stack trace:
#0 /PATH/framework/yiilite.php(3100): TerminalController->renderInternal()
#1 /PATH/framework/yiilite.php(3524): TerminalController->renderFile()
#2 /PATH/framework/yiilite.php(3492): TerminalController->renderPartial()
#3 /PATH/app/protected/controllers/TerminalController.php(38): TerminalController->render()
#4 /PATH/framework/yiilite.php(3760): TerminalController->actionIndex()
#5 /PATH/framework/yiilite.php(3272): CInlineAction->runWithParams()
#6 /PATH/framework/yiilite.php(6526): TerminalController->runAction()
#7 /PATH/framework/yiilite.php(6535): CFilterChain->run()
#8 /PATH/app/protected/components/system/Controller.php(60): AccessControlFilter->filter()
#9 /PATH/framework/yiilite.php(6568): TerminalController->filterAccessControl()
#10 /PATH/framework/yiilite.php(6523): CInlineFilter->filter()
#11 /PATH/framework/yiilite.php(3262): CFilterChain->run()
#12 /PATH/framework/yiilite.php(3247): TerminalController->runActionWithFilters()
#13 /PATH/framework/yiilite.php(1689): TerminalController->run()
#14 /PATH/framework/yiilite.php(1609): CWebApplication->runController()
#15 /PATH/framework/yiilite.php(1135): CWebApplication->processRequest()
#16 /PATH/app/index.php(21): CWebApplication->run()
REQUEST_URI=/terminal
Either $terminalReport
or its relation terminal
does not exist in the database on your dev environment. Debug this code with a var_dump
of $terminalReport
and $terminalReport->terminal
to check which value is null.
It seems the errors I was receiving were actually valid errors but they should have been ignored for this application.
By setting error_reporting in my php.ini to
error_reporting = E_ERROR
I was able to solve this issue.