Symfony Exception

FatalThrowableError

HTTP 500 Internal Server Error

Call to a member function getViewingcount() on null

Exception

Symfony\Component\Debug\Exception\ FatalThrowableError

  1.         $em $this->getDoctrine();
  2.         $newsRepository $em->getRepository('AdminBundle:News');
  3.         $new $newsRepository->findOneBy(['id' => $id]);
  4.         $newview $new->getViewingcount() + 1;
  5.         $new->setViewingcount($newview);
  6.         $em->getManager()->persist($new);
  7.         $em->getManager()->flush();
  8.         $commentsRepository $em->getRepository('AdminBundle:Newscomments');
AppController->news_viewAction('558', object(Request)) in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php (line 151)
  1.         $this->dispatcher->dispatch(KernelEvents::CONTROLLER_ARGUMENTS$event);
  2.         $controller $event->getController();
  3.         $arguments $event->getArguments();
  4.         // call controller
  5.         $response = \call_user_func_array($controller$arguments);
  6.         // view
  7.         if (!$response instanceof Response) {
  8.             $event = new GetResponseForControllerResultEvent($this$request$type$response);
  9.             $this->dispatcher->dispatch(KernelEvents::VIEW$event);
HttpKernel->handleRaw(object(Request), 1) in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php (line 68)
  1.     public function handle(Request $request$type HttpKernelInterface::MASTER_REQUEST$catch true)
  2.     {
  3.         $request->headers->set('X-Php-Ob-Level'ob_get_level());
  4.         try {
  5.             return $this->handleRaw($request$type);
  6.         } catch (\Exception $e) {
  7.             if ($e instanceof RequestExceptionInterface) {
  8.                 $e = new BadRequestHttpException($e->getMessage(), $e);
  9.             }
  10.             if (false === $catch) {
HttpKernel->handle(object(Request), 1, true) in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php (line 200)
  1.         $this->boot();
  2.         ++$this->requestStackSize;
  3.         $this->resetServices true;
  4.         try {
  5.             return $this->getHttpKernel()->handle($request$type$catch);
  6.         } finally {
  7.             --$this->requestStackSize;
  8.         }
  9.     }
Kernel->handle(object(Request)) in web/app.php (line 44)
  1. //$kernel = new AppCache($kernel);
  2. // When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
  3. //Request::enableHttpMethodParameterOverride();
  4.     $request Request::createFromGlobals();
  5.     $response $kernel->handle($request);
  6.     $response->send();
  7.     $kernel->terminate($request$response);
  8. }

Logs

No log messages

Stack Trace

FatalThrowableError

Symfony\Component\Debug\Exception\FatalThrowableError:
Call to a member function getViewingcount() on null

  at src/BlogBundle/Controller/AppController.php:201
  at BlogBundle\Controller\AppController->news_viewAction('558', object(Request))
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:151)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:68)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:200)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (web/app.php:44)