Symfony Exception

RuntimeError

HTTP 500 Internal Server Error

Impossible to access an attribute ("mainRegion") on a null variable.

Exception

Twig\Error\ RuntimeError

  1.     {% if winery.addressZip %}<meta itemprop="postalCode" content="{{ winery.addressZip }}" />{% endif %}
  2.     {% if winery.addressCountry %}<meta itemprop="addressCountry" content="{{ winery.addressCountry.iso }}" />{% endif %}
  3.     <iframe loading="lazy" title="{{ 'winery_location' | trans({'%winery%': winery.name}, "winedexer", language) }}" src="https://www.google.com/maps/embed/v1/place?&zoom=8&maptype=satellite&key=AIzaSyBfVEdM-gypd9wdSqX4jrt8_w6HYrcH2JM&q={{ wineData.location.latitude }},{{ wineData.location.longitude }}" allowfullscreen></iframe>
  4. {% elseif winery.addressAddress and winery.addressCity and winery.addressZip %}
  5.     <iframe loading="lazy" title="{{ 'winery_location' | trans({'%winery%': winery.name}, "winedexer", language) }}" src="https://www.google.com/maps/embed/v1/place?&zoom=8&maptype=satellite&key=AIzaSyBfVEdM-gypd9wdSqX4jrt8_w6HYrcH2JM&q={{ winery.addressAddress }}, {{ winery.addressZip }} {{ winery.addressCity }},{{ winery.addressCountry.name }}" allowfullscreen></iframe>
  6. {% elseif winery.addressRegion.mainRegion and winery.addressRegion and winery.addressCountry %}
  7.     <iframe loading="lazy" title="{{ 'winery_location' | trans({'%winery%': winery.name}, "winedexer", language) }}" src="https://www.google.com/maps/embed/v1/search?&zoom=9&maptype=satellite&key=AIzaSyBfVEdM-gypd9wdSqX4jrt8_w6HYrcH2JM&q={% if winery.addressRegion.mainRegion != winery.addressRegion %}{{ winery.addressRegion.name }}, {% endif %}{{ winery.addressRegion.mainRegion.name }},{{ winery.addressCountry.name }}" allowfullscreen></iframe>
  8. {% endif %}
  1.             echo ",";
  2.             echo twig_escape_filter($this->envtwig_get_attribute($this->env$this->sourcetwig_get_attribute($this->env$this->source, (isset($context["winery"]) || array_key_exists("winery"$context) ? $context["winery"] : (function () { throw new RuntimeError('Variable "winery" does not exist.'14$this->source); })()), "addressCountry", [], "any"falsefalsefalse14), "name", [], "any"falsefalsefalse14), "html"nulltrue);
  3.             echo "\" allowfullscreen></iframe>
  4. ";
  5.         } elseif (((twig_get_attribute($this->env$this->sourcetwig_get_attribute($this->env$this->source,         // line 15
  6. (isset($context["winery"]) || array_key_exists("winery"$context) ? $context["winery"] : (function () { throw new RuntimeError('Variable "winery" does not exist.'15$this->source); })()), "addressRegion", [], "any"falsefalsefalse15), "mainRegion", [], "any"falsefalsefalse15) && twig_get_attribute($this->env$this->source, (isset($context["winery"]) || array_key_exists("winery"$context) ? $context["winery"] : (function () { throw new RuntimeError('Variable "winery" does not exist.'15$this->source); })()), "addressRegion", [], "any"falsefalsefalse15)) && twig_get_attribute($this->env$this->source, (isset($context["winery"]) || array_key_exists("winery"$context) ? $context["winery"] : (function () { throw new RuntimeError('Variable "winery" does not exist.'15$this->source); })()), "addressCountry", [], "any"falsefalsefalse15))) {
  7.             // line 16
  8.             echo "\t<iframe loading=\"lazy\" title=\"";
  9.             echo twig_escape_filter($this->env$this->extensions['Symfony\Bridge\Twig\Extension\TranslationExtension']->trans("winery_location", ["%winery%" => twig_get_attribute($this->env$this->source, (isset($context["winery"]) || array_key_exists("winery"$context) ? $context["winery"] : (function () { throw new RuntimeError('Variable "winery" does not exist.'16$this->source); })()), "name", [], "any"falsefalsefalse16)], "winedexer", (isset($context["language"]) || array_key_exists("language"$context) ? $context["language"] : (function () { throw new RuntimeError('Variable "language" does not exist.'16$this->source); })())), "html"nulltrue);
  10.             echo "\" src=\"https://www.google.com/maps/embed/v1/search?&zoom=9&maptype=satellite&key=AIzaSyBfVEdM-gypd9wdSqX4jrt8_w6HYrcH2JM&q=";
  11.             if ((!== twig_compare(twig_get_attribute($this->env$this->sourcetwig_get_attribute($this->env$this->source, (isset($context["winery"]) || array_key_exists("winery"$context) ? $context["winery"] : (function () { throw new RuntimeError('Variable "winery" does not exist.'16$this->source); })()), "addressRegion", [], "any"falsefalsefalse16), "mainRegion", [], "any"falsefalsefalse16), twig_get_attribute($this->env$this->source, (isset($context["winery"]) || array_key_exists("winery"$context) ? $context["winery"] : (function () { throw new RuntimeError('Variable "winery" does not exist.'16$this->source); })()), "addressRegion", [], "any"falsefalsefalse16)))) {
in vendor/twig/twig/src/Template.php -> doDisplay (line 394)
  1.     }
  2.     protected function displayWithErrorHandling(array $context, array $blocks = [])
  3.     {
  4.         try {
  5.             $this->doDisplay($context$blocks);
  6.         } catch (Error $e) {
  7.             if (!$e->getSourceContext()) {
  8.                 $e->setSourceContext($this->getSourceContext());
  9.             }
in vendor/twig/twig/src/Template.php -> displayWithErrorHandling (line 367)
  1.         return $this->blocks;
  2.     }
  3.     public function display(array $context, array $blocks = [])
  4.     {
  5.         $this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks$blocks));
  6.     }
  7.     public function render(array $context)
  8.     {
  9.         $level ob_get_level();
  1.                 </p>
  2.             </div>
  3.             <div class=\"col-12 col-lg-8\">
  4.                 ";
  5.         // line 445
  6.         $this->loadTemplate("shop/single/map.html.twig""shop/wine.html.twig"445)->display(twig_array_merge($context, ["winery" => twig_get_attribute($this->env$this->source, (isset($context["wine"]) || array_key_exists("wine"$context) ? $context["wine"] : (function () { throw new RuntimeError('Variable "wine" does not exist.'445$this->source); })()), "winery", [], "any"falsefalsefalse445), "wineData" => (isset($context["wineData"]) || array_key_exists("wineData"$context) ? $context["wineData"] : (function () { throw new RuntimeError('Variable "wineData" does not exist.'445$this->source); })())]));
  7.         // line 446
  8.         echo "            </div>
  9.         </div>
  10.     </div>
  11.     <div id=\"wine-top\" class=\"container-fluid\" style=\"background-image: url('/image/region/";
in vendor/twig/twig/src/Template.php -> doDisplay (line 394)
  1.     }
  2.     protected function displayWithErrorHandling(array $context, array $blocks = [])
  3.     {
  4.         try {
  5.             $this->doDisplay($context$blocks);
  6.         } catch (Error $e) {
  7.             if (!$e->getSourceContext()) {
  8.                 $e->setSourceContext($this->getSourceContext());
  9.             }
in vendor/twig/twig/src/Template.php -> displayWithErrorHandling (line 367)
  1.         return $this->blocks;
  2.     }
  3.     public function display(array $context, array $blocks = [])
  4.     {
  5.         $this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks$blocks));
  6.     }
  7.     public function render(array $context)
  8.     {
  9.         $level ob_get_level();
in vendor/twig/twig/src/Template.php -> display (line 379)
  1.             ob_start();
  2.         } else {
  3.             ob_start(function () { return ''; });
  4.         }
  5.         try {
  6.             $this->display($context);
  7.         } catch (\Throwable $e) {
  8.             while (ob_get_level() > $level) {
  9.                 ob_end_clean();
  10.             }
  1.     public function render(array $context = []): string
  2.     {
  3.         // using func_get_args() allows to not expose the blocks argument
  4.         // as it should only be used by internal code
  5.         return $this->template->render($context, \func_get_args()[1] ?? []);
  6.     }
  7.     public function display(array $context = [])
  8.     {
  9.         // using func_get_args() allows to not expose the blocks argument
  1.      * @throws SyntaxError  When an error occurred during compilation
  2.      * @throws RuntimeError When an error occurred during rendering
  3.      */
  4.     public function render($name, array $context = []): string
  5.     {
  6.         return $this->load($name)->render($context);
  7.     }
  8.     /**
  9.      * Displays a template.
  10.      *
  1.     {
  2.         if (!$this->container->has('twig')) {
  3.             throw new \LogicException('You can not use the "renderView" method if the Twig Bundle is not available. Try running "composer require symfony/twig-bundle".');
  4.         }
  5.         return $this->container->get('twig')->render($view$parameters);
  6.     }
  7.     /**
  8.      * Renders a view.
  9.      */
AbstractController->renderView() in src/Controller/Vinotek/WineController.php (line 432)
  1.             'structure' => $structure,
  2.             'descriptions' =>  $desc,
  3.             'description' => $description,
  4.             'metas' => $metas,
  5.             'news' => $news,
  6.             'server' => $_ENV['PROJECT_VNK_SERVER_URL'],
  7.           )
  8.         )),
  9.       );
  10.     });
in vendor/symfony/cache/LockRegistry.php -> App\Controller\Vinotek\{closure} (line 105)
  1.                 if ($locked || !$wouldBlock) {
  2.                     $logger && $logger->info(sprintf('Lock %s, now computing item "{key}"'$locked 'acquired' 'not supported'), ['key' => $item->getKey()]);
  3.                     self::$lockedFiles[$key] = true;
  4.                     $value $callback($item$save);
  5.                     if ($save) {
  6.                         if ($setMetadata) {
  7.                             $setMetadata($item);
  8.                         }
  1.             }
  2.             try {
  3.                 $value = ($this->callbackWrapper)($callback$item$save$pool, function (CacheItem $item) use ($setMetadata$startTime, &$metadata) {
  4.                     $setMetadata($item$startTime$metadata);
  5.                 }, $this->logger ?? null);
  6.                 $setMetadata($item$startTime$metadata);
  7.                 return $value;
  8.             } finally {
  9.                 unset($this->computing[$key]);
in vendor/symfony/cache-contracts/CacheTrait.php -> Symfony\Component\Cache\Traits\{closure} (line 72)
  1.             }
  2.         }
  3.         if ($recompute) {
  4.             $save true;
  5.             $item->set($callback($item$save));
  6.             if ($save) {
  7.                 $pool->save($item);
  8.             }
  9.         }
  1.                 return $value;
  2.             } finally {
  3.                 unset($this->computing[$key]);
  4.             }
  5.         }, $beta$metadata$this->logger ?? null);
  6.     }
  7. }
  1.      *
  2.      * @return mixed
  3.      */
  4.     public function get(string $key, callable $callbackfloat $beta null, array &$metadata null)
  5.     {
  6.         return $this->doGet($this$key$callback$beta$metadata);
  7.     }
  8.     /**
  9.      * {@inheritdoc}
  10.      */
AbstractAdapter->get() in src/Controller/Vinotek/WineController.php (line 436)
  1.             'news' => $news,
  2.             'server' => $_ENV['PROJECT_VNK_SERVER_URL'],
  3.           )
  4.         )),
  5.       );
  6.     });
  7.     $langs $this->utilsController->getAvailableLanguages();
  8.     if (empty($body['metas']['url']) || !is_array($body['metas']['url']) || count($body['metas']['url']) < count($langs)) {
  9.       $winery $this->scrapWineryRepository->findOneBy(array('url' => $wineryPath));
  10.             if (empty($winery)) {
  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);
  9.             $this->dispatcher->dispatch($eventKernelEvents::VIEW);
  1.     public function handle(Request $requestint $type HttpKernelInterface::MAIN_REQUESTbool $catch true)
  2.     {
  3.         $request->headers->set('X-Php-Ob-Level', (string) 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) {
  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 35)
  1. $app $app(...$args);
  2. exit(
  3.     $runtime
  4.         ->getRunner($app)
  5.         ->run()
  6. );
require_once('/var/www/winemakers/wine-makers-core/vendor/autoload_runtime.php') in public/index.php (line 5)
  1. <?php
  2. use App\Kernel;
  3. require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
  4. return function (array $context) {
  5.     return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
  6. };

Logs

No log messages

Stack Trace

RuntimeError
Twig\Error\RuntimeError:
Impossible to access an attribute ("mainRegion") on a null variable.

  at templates/shop/single/map.html.twig:15
  at twig_get_attribute()
     (var/cache/prod/twig/32/32bbd2149c546c4244039251aaebada420a09a761ee6ccd59ae6b81987fea38a.php:137)
  at __TwigTemplate_697c8d16c7b8f1ec981098eff88c2b71a9a2cdd098048203b310408e35e74020->doDisplay()
     (vendor/twig/twig/src/Template.php:394)
  at Twig\Template->displayWithErrorHandling()
     (vendor/twig/twig/src/Template.php:367)
  at Twig\Template->display()
     (var/cache/prod/twig/b1/b12cc39e24bb6b648143abf9571fd46fb1303ba84c27263539a1d190d7cd2e75.php:1370)
  at __TwigTemplate_6b8c50f4b3ee837e2b0d75436332bdf6f6c565b9f86818d05bc57462c92709c1->doDisplay()
     (vendor/twig/twig/src/Template.php:394)
  at Twig\Template->displayWithErrorHandling()
     (vendor/twig/twig/src/Template.php:367)
  at Twig\Template->display()
     (vendor/twig/twig/src/Template.php:379)
  at Twig\Template->render()
     (vendor/twig/twig/src/TemplateWrapper.php:40)
  at Twig\TemplateWrapper->render()
     (vendor/twig/twig/src/Environment.php:280)
  at Twig\Environment->render()
     (vendor/symfony/framework-bundle/Controller/AbstractController.php:251)
  at Symfony\Bundle\FrameworkBundle\Controller\AbstractController->renderView()
     (src/Controller/Vinotek/WineController.php:432)
  at App\Controller\Vinotek\WineController->App\Controller\Vinotek\{closure}()
     (vendor/symfony/cache/LockRegistry.php:105)
  at Symfony\Component\Cache\LockRegistry::compute()
     (vendor/symfony/cache/Traits/ContractsTrait.php:100)
  at Symfony\Component\Cache\Adapter\AbstractAdapter->Symfony\Component\Cache\Traits\{closure}()
     (vendor/symfony/cache-contracts/CacheTrait.php:72)
  at Symfony\Component\Cache\Adapter\AbstractAdapter->doGet()
     (vendor/symfony/cache/Traits/ContractsTrait.php:107)
  at Symfony\Component\Cache\Adapter\AbstractAdapter->doGet()
     (vendor/symfony/cache-contracts/CacheTrait.php:35)
  at Symfony\Component\Cache\Adapter\AbstractAdapter->get()
     (src/Controller/Vinotek/WineController.php:436)
  at App\Controller\Vinotek\WineController->wineAction()
     (vendor/symfony/http-kernel/HttpKernel.php:156)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw()
     (vendor/symfony/http-kernel/HttpKernel.php:78)
  at Symfony\Component\HttpKernel\HttpKernel->handle()
     (vendor/symfony/http-kernel/Kernel.php:199)
  at Symfony\Component\HttpKernel\Kernel->handle()
     (vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:37)
  at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run()
     (vendor/autoload_runtime.php:35)
  at require_once('/var/www/winemakers/wine-makers-core/vendor/autoload_runtime.php')
     (public/index.php:5)