@sattva2012

YII2 — PHP Notice – yii\base\ErrorException?

На действующем сайте при его открытии возникла вот такая ошибка:
PHP Notice – yii\base\ErrorException

Trying to get property of non-object



1. in /home/asklepiy/public_html/backend/modules/page/models/Page.php at line 228
219220221222223224225226227228229230231232233234235236237 return self::find()
->joinWith(['t'])
->where(['depth'=>1,'show_in_menu'=>'1'])
->orderBy('left desc')
// ->asArray()
->all();
}

public static function getUslugi($main_page){
return self::find()->with(['t'])->where('`left`>'.$main_page->left.' and `right`<'.$main_page->right.' and `depth`=2')->andWhere(["show" => '1'])->orderBy('left desc')->all();
}

public static function getMainPage(){
return self::find()->with(['t'])->where(['main_page'=>'1'])->one();
}

public static function getForServices(){
return self::find()
->where(['translit' => ''])
2. in /home/asklepiy/public_html/backend/modules/page/models/Page.php at line 228 – yii\base\ErrorHandler::handleError(8, 'Trying to get property of non-ob...', '/home/asklepiy/public_html/backe...', 228, ...)
222223224225226227228229230231232233234 ->orderBy('left desc')
// ->asArray()
->all();
}

public static function getUslugi($main_page){
return self::find()->with(['t'])->where('`left`>'.$main_page->left.' and `right`<'.$main_page->right.' and `depth`=2')->andWhere(["show" => '1'])->orderBy('left desc')->all();
}

public static function getMainPage(){
return self::find()->with(['t'])->where(['main_page'=>'1'])->one();
}

3. in /home/asklepiy/public_html/frontend/controllers/SiteController.php at line 921 – backend\modules\page\models\Page::getUslugi(null)
915916917918919920921922923924925926927 * Главная страница
* @inheritdoc
*/
public function actionHome()
{
$main_page=Page::getMainPage();
$uslugi=Page::getUslugi($main_page);

if($main_page){
$this->view->title = ($main_page->t->seo_title) ? $main_page->t->seo_title : str_replace("
"," ",$main_page->t->name);
Yii::$app->controller->view->registerMetaTag(['name' => 'description','content' => $main_page->t->seo_descr],'description');
Yii::$app->controller->view->registerMetaTag(['name' => 'keywords','content' => $main_page->t->seo_keywords],'keywords');
}
4. frontend\controllers\SiteController::actionHome()
5. in /home/asklepiy/public_html/vendor/yiisoft/yii2/base/InlineAction.php at line 55 – call_user_func_array([frontend\controllers\SiteController, 'actionHome'], [])
6. in /home/asklepiy/public_html/vendor/yiisoft/yii2/base/Controller.php at line 151 – yii\base\InlineAction::runWithParams([])
7. in /home/asklepiy/public_html/vendor/yiisoft/yii2/base/Module.php at line 455 – yii\base\Controller::runAction('home', [])
8. in /home/asklepiy/public_html/vendor/yiisoft/yii2/web/Application.php at line 84 – yii\base\Module::runAction('site/home', [])
9. in /home/asklepiy/public_html/vendor/yiisoft/yii2/base/Application.php at line 375 – yii\web\Application::handleRequest(common\components\Request)
10. in /home/asklepiy/public_html/frontend/web/index.php at line 20 – yii\base\Application::run()
14151617181920 require(__DIR__ . '/../config/main-local.php')
);
//\yii\helpers\VarDumper::dump($config,6,1);
//die();
//use app\components;
$application = new yii\web\Application($config);
$application->run();
$_SERVER = [
'CONTEXT_DOCUMENT_ROOT' => '/home/asklepiy/public_html',
'CONTEXT_PREFIX' => '',
'DOCUMENT_ROOT' => '/home/asklepiy/public_html',
'GATEWAY_INTERFACE' => 'CGI/1.1',
'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.8,ru;q=0.6',
'HTTP_CACHE_CONTROL' => 'no-cache',
'HTTP_CONNECTION' => 'close',
'HTTP_COOKIE' => '_ym_uid=1494356152157295238; __unam=7639673-15bee917b40-d11e822-18; jv_enter_ts_vSuOnjdzhq=1494751980215; jv_visits_count_vSuOnjdzhq=3; _ga=GA1.2.1231594282.1494356152; _gid=GA1.2.1422274177.1494757197; jv_pages_count_vSuOnjdzhq=5; jv_invitation_time_vSuOnjdzhq=1494757209680; jv_close_time_vSuOnjdzhq=1494757341196; PHPSESSID=44hc06u60ca8e4bjibriva1r17; _identity=d0622cac5a81958d605bf6a272dc591b3d2b1f16fb08239709c2d872f8e460a9a%3A2%3A%7Bi%3A0%3Bs%3A9%3A%22_identity%22%3Bi%3A1%3Bs%3A48%3A%22%5B179%2C%22YpCgjj8XEFMzDjZf7hvlgT6ohVmQvU_N%22%2C2592000%5D%22%3B%7D; geo=1',
'HTTP_HOST' => 'asklepiy.com',
'HTTP_PRAGMA' => 'no-cache',
'HTTP_UPGRADE_INSECURE_REQUESTS' => '1',
'HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.5.3029.81 Safari/537.36',
'HTTP_X_FORWARDED_FOR' => '37.115.91.44',
'HTTP_X_FORWARDED_HOST' => 'asklepiy.com',
'HTTP_X_FORWARDED_SERVER' => 'asklepiy.com',
'HTTP_X_REAL_IP' => '192.168.88.249',
'HTTP_X_VARNISH' => '117135230',
'PATH' => '/bin:/usr/bin:/usr/local/php/bin',
'PHPRC' => '/home/asklepiy',
'QUERY_STRING' => '',
'REDIRECT_STATUS' => '200',
'REDIRECT_UNIQUE_ID' => 'WRjAEX8AAAEAAAkEkg0AAAAQ',
'REDIRECT_URL' => '/',
'REMOTE_ADDR' => '37.115.91.44',
'REMOTE_PORT' => '45506',
'REQUEST_METHOD' => 'GET',
'REQUEST_SCHEME' => 'http',
'REQUEST_URI' => '/',
'SCRIPT_FILENAME' => '/home/asklepiy/public_html/frontend/web/index.php',
'SCRIPT_NAME' => '/frontend/web/index.php',
'SERVER_ADDR' => '192.168.88.249',
'SERVER_ADMIN' => 'ruslan.griban@gmail.com',
'SERVER_NAME' => 'asklepiy.com',
'SERVER_PORT' => '80',
'SERVER_PROTOCOL' => 'HTTP/1.0',
'SERVER_SIGNATURE' => '',
'SERVER_SOFTWARE' => 'Apache/2.4.25 (Unix) OpenSSL/1.0.1e-fips',
'UNIQUE_ID' => 'WRjAEX8AAAEAAAkEkg0AAAAQ',
'PHP_SELF' => '/frontend/web/index.php',
'REQUEST_TIME_FLOAT' => 1494794257.522613,
'REQUEST_TIME' => 1494794257,
];

$_COOKIE = [
'_ym_uid' => '1494356152157295238',
'__unam' => '7639673-15bee917b40-d11e822-18',
'jv_enter_ts_vSuOnjdzhq' => '1494751980215',
'jv_visits_count_vSuOnjdzhq' => '3',
'_ga' => 'GA1.2.1231594282.1494356152',
'_gid' => 'GA1.2.1422274177.1494757197',
'jv_pages_count_vSuOnjdzhq' => '5',
'jv_invitation_time_vSuOnjdzhq' => '1494757209680',
'jv_close_time_vSuOnjdzhq' => '1494757341196',
'PHPSESSID' => '44hc06u60ca8e4bjibriva1r17',
'_identity' => 'd0622cac5a81958d605bf6a272dc591b3d2b1f16fb08239709c2d872f8e460a9a:2:{i:0;s:9:"_identity";i:1;s:48:"[179,"YpCgjj8XEFMzDjZf7hvlgT6ohVmQvU_N",2592000]";}',
'geo' => '1',
];

$_SESSION = [
'__flash' => [],
'__returnUrl' => '/',
'__id' => 179,
];
Yii Framework
2017-05-14, 20:37:37

Apache/2.4.25 (Unix) OpenSSL/1.0.1e-fips
Yii Framework/2.0.6


В чем может быть проблема?
  • Вопрос задан
  • 1676 просмотров
Пригласить эксперта
Ответы на вопрос 2
qonand
@qonand
Software Engineer
В ошибке же четко сказано
Trying to get property of non-object

in /home/asklepiy/public_html/backend/modules/page/models/Page.php at line 228

Вы пытаетесь обратиться к свойству несуществующего объекта в 228 строке файла Page.php
Ответ написан
Комментировать
@sattva2012 Автор вопроса
Максим ищем программиста на для SEO-оптимизации нашего сайта, на базе фрилансера. Мой скайп - sattva2005
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы