Symfony Exception

Error

HTTP 500 Internal Server Error

Call to a member function getUser() on null

Exception

Error

  1.      * @return AnimalPoll
  2.      */
  3.     public function preparePollEntity($animalId$animalPollToken null)
  4.     {
  5.         $animalPoll null;
  6.         $user $this->tokenStorage->getToken()->getUser();
  7.         if (!$user instanceof User) {
  8.             $user null;
  9.         }
AdoptionPollService->preparePollEntity() in src/Controller/Front/AnimalController.php (line 292)
  1.     }
  2.     #[Route('/{id}/ankieta/{animalPollToken}/{step}')]
  3.     public function pollAction(Request $requestAdoptionPollService $adoptionPollService$id$animalPollToken 0$step 0)
  4.     {
  5.         $animalPoll $adoptionPollService->preparePollEntity($id$animalPollToken);
  6.         $returnForm $adoptionPollService->prepareForm($animalPoll);
  7.         //synchronize steps if necessary
  8.         if (!$request->isMethod('POST') && $step != $animalPoll->getCurrentStep()) {
  9.             return $this->redirectToRoute(
  1.         $this->dispatcher->dispatch($eventKernelEvents::CONTROLLER_ARGUMENTS);
  2.         $controller $event->getController();
  3.         $arguments $event->getArguments();
  4.         // call controller
  5.         $response $controller(...$arguments);
  6.         // view
  7.         if (!$response instanceof Response) {
  8.             $event = new ViewEvent($this$request$type$response$event);
  9.             $this->dispatcher->dispatch($eventKernelEvents::VIEW);
  1.     {
  2.         $request->headers->set('X-Php-Ob-Level', (string) ob_get_level());
  3.         $this->requestStack->push($request);
  4.         try {
  5.             return $this->handleRaw($request$type);
  6.         } catch (\Throwable $e) {
  7.             if ($e instanceof \Error && !$this->handleAllThrowables) {
  8.                 throw $e;
  9.             }
  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.     }
  1.         $this->request $request;
  2.     }
  3.     public function run(): int
  4.     {
  5.         $response $this->kernel->handle($this->request);
  6.         $response->send();
  7.         if ($this->kernel instanceof TerminableInterface) {
  8.             $this->kernel->terminate($this->request$response);
  9.         }
in vendor/autoload_runtime.php -> run (line 29)
  1. $app $app(...$args);
  2. exit(
  3.     $runtime
  4.         ->getRunner($app)
  5.         ->run()
  6. );
require_once('/home/adopt/web/adopciaki.pl/public_html/vendor/autoload_runtime.php') in public/index.php (line 6)
  1. <?php
  2. use App\Kernel;
  3. use Symfony\Component\HttpFoundation\Request;
  4. require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
  5. return function (array $context) {
  6.     $request Request::createFromGlobals();
  7.     if($request->getClientIp() == "95.217.17.2") {

Logs

No log messages

Stack Trace

Error
Error:
Call to a member function getUser() on null

  at src/Service/AdoptionPollService.php:168
  at App\Service\AdoptionPollService->preparePollEntity()
     (src/Controller/Front/AnimalController.php:292)
  at App\Controller\Front\AnimalController->pollAction()
     (vendor/symfony/http-kernel/HttpKernel.php:163)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw()
     (vendor/symfony/http-kernel/HttpKernel.php:74)
  at Symfony\Component\HttpKernel\HttpKernel->handle()
     (vendor/symfony/http-kernel/Kernel.php:184)
  at Symfony\Component\HttpKernel\Kernel->handle()
     (vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:35)
  at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run()
     (vendor/autoload_runtime.php:29)
  at require_once('/home/adopt/web/adopciaki.pl/public_html/vendor/autoload_runtime.php')
     (public/index.php:6)