Symfony Exception

ErrorException

HTTP 500 Internal Server Error

Warning: foreach() argument must be of type array|object, null given

Exception

ErrorException

  1.         $cacheKey 'expertises';
  2.         $cacheClosure = function (ItemInterface $item) {
  3.             $item->expiresAfter($this->getCacheDuration());
  4.             $list $this->get("expertise/");
  5.             $return = [];
  6.             foreach ($list as $s) {
  7.                 $return[] = (new Expertise())->setId($s->id)->setName($s->name)->setKeyword($s->keyword);
  8.             }
  9.             usort($return, function (Expertise $aExpertise $b) {
  10.                 return $a->getName() <=> $b->getName();
  11.             });
in vendor/symfony/cache/LockRegistry.php -> App\Service\{closure} (line 113)
  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('expertises-es-AR', object(Closure)) in src/Service/EmdRestService.php (line 106)
  1.     }
  2.     private function getKey($cacheKey$cacheClosure)
  3.     {
  4.         $cacheKey .= '-' $this->localeService->getCurrent();
  5.         $result $this->cache->get($cacheKey$cacheClosure);
  6.         if (!$result || (is_array($result) && == count($result))) {
  7.             $this->cache->delete($cacheKey);
  8.         }
  9.         return $result;
  10.     }
EmdRestService->getKey('expertises-es-AR', object(Closure)) in src/Service/EmdRestService.php (line 139)
  1.                 return $a->getName() <=> $b->getName();
  2.             });
  3.             return $return;
  4.         };
  5.         return $this->getKey($cacheKey$cacheClosure);
  6.     }
  7.     private function getCertificationAssociated($id)
  8.     {
EmdRestService->getExpertises() in src/Controller/Web/ListeCertificationsController.php (line 33)
  1.     {
  2.         return $this->renderView('liste_certifications/index.html.twig', [
  3.             'bodyClass' => 'liste_certifications',
  4.             'headerClass' => 'whiteTransparent',
  5.             'controller_name' => 'ListeCertificationsController',
  6.             'expertises' => $this->emd->getExpertises(),
  7.             'sectors' => $this->emd->getSectors(),
  8.             'certifications' => $this->emd->getFullDetailledCertifications(),
  9.             'routeName' => 'liste_certifications',
  10.         ]);
  11.     }
ListeCertificationsController->getHtmlContent() in src/Controller/Web/ListeCertificationsController.php (line 19)
  1. {
  2.     public function index(Security $securityCacheItemPoolInterface $cache$cacheForPerformance)
  3.     {
  4.         if ($cacheForPerformance || !$security->isGranted('ROLE_ADMIN')) {
  5.             $html $this->getHtmlContent();
  6.         } else {
  7.             $html $cache->get('liste-certifications-' $this->getLocale()->getCode(), fn() => $this->getHtmlContent());
  8.         }
  9.         return new Response($html);
  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.     {
  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 (\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.     }
Kernel->handle(object(Request)) in public/index.php (line 25)
  1.     Request::setTrustedHosts([$trustedHosts]);
  2. }
  3. $kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
  4. $request Request::createFromGlobals();
  5. $response $kernel->handle($request);
  6. $response->send();
  7. $kernel->terminate($request$response);

Logs

No log messages

Stack Trace

ErrorException
ErrorException:
Warning: foreach() argument must be of type array|object, null given

  at src/Service/EmdRestService.php:130
  at App\Service\EmdRestService->App\Service\{closure}(object(CacheItem), true)
     (vendor/symfony/cache/LockRegistry.php:113)
  at Symfony\Component\Cache\LockRegistry::compute(object(Closure), object(CacheItem), true, object(RedisAdapter), object(Closure), object(Logger))
     (vendor/symfony/cache/Traits/ContractsTrait.php:100)
  at Symfony\Component\Cache\Adapter\AbstractAdapter->Symfony\Component\Cache\Traits\{closure}(object(CacheItem), true)
     (vendor/symfony/cache-contracts/CacheTrait.php:72)
  at Symfony\Component\Cache\Adapter\AbstractAdapter->contractsGet(object(RedisAdapter), 'expertises-es-AR', object(Closure), 1.0, array(), object(Logger))
     (vendor/symfony/cache/Traits/ContractsTrait.php:107)
  at Symfony\Component\Cache\Adapter\AbstractAdapter->doGet(object(RedisAdapter), 'expertises-es-AR', object(Closure), 1.0, array())
     (vendor/symfony/cache-contracts/CacheTrait.php:35)
  at Symfony\Component\Cache\Adapter\AbstractAdapter->get('expertises-es-AR', object(Closure))
     (src/Service/EmdRestService.php:106)
  at App\Service\EmdRestService->getKey('expertises-es-AR', object(Closure))
     (src/Service/EmdRestService.php:139)
  at App\Service\EmdRestService->getExpertises()
     (src/Controller/Web/ListeCertificationsController.php:33)
  at App\Controller\Web\ListeCertificationsController->getHtmlContent()
     (src/Controller/Web/ListeCertificationsController.php:19)
  at App\Controller\Web\ListeCertificationsController->index(object(Security), object(RedisAdapter), true)
     (vendor/symfony/http-kernel/HttpKernel.php:163)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/http-kernel/HttpKernel.php:75)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/http-kernel/Kernel.php:202)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (public/index.php:25)