Добрый день, в блоге при запросе ,например http://localhost/index.php/site/99 или любую другую страницу с несуществующем ID статьи ,-выдаёт не понятную мне ошибку ,приблизительно понимаю что это в Б/Д, но я уже что только не пробовал, если задать запрос например http://localhost/index.php/site/dtfxgkukdc - то всё происходит как положено, отрабатывает этот код: Код (Text): <?php header ("HTTP/1.0 404 Not Found"); ?> <script> document.location="http://my_site"; </script> Что это за ошибка и как её побороть ? Call to a member function getArticleComments() on null 1. in /var/www/example.com/basic/controllers/SiteController.php at line 143 public function actionView($id) { $article = Article::findOne($id); $popular = Article::getPopular(); $recent = Article::getRecent(); $categories = Category::getAll(); $comments = $article->getArticleComments(); - line 143 $commentForm = new CommentForm(); $article->viewedCounter(); return $this->render('single',[ 'article'=>$article, 'popular'=>$popular, 'recent'=>$recent, 'categories'=>$categories, 'comments'=>$comments,
Код (Text): if (!$article = Article::findOne($id)) { thrown new NotFoundHttpException('Article not found'); }
добавил use yii\web\NotFoundHttpException; и этот код обработчик теперь работает как положено. Спасибо..