Symfony Exception

RuntimeException

HTTP 500 Internal Server Error

Failed to start the session because headers have already been sent by "/var/www/goodycs/src/Controller/Products/categoryController.php" at line 523.

Exception

RuntimeException

  1.         if (\PHP_SESSION_ACTIVE === session_status()) {
  2.             throw new \RuntimeException('Failed to start the session: already started by PHP.');
  3.         }
  4.         if (filter_var(\ini_get('session.use_cookies'), \FILTER_VALIDATE_BOOLEAN) && headers_sent($file$line)) {
  5.             throw new \RuntimeException(sprintf('Failed to start the session because headers have already been sent by "%s" at line %d.'$file$line));
  6.         }
  7.         $sessionId $_COOKIE[session_name()] ?? null;
  8.         /*
  9.          * Explanation of the session ID regular expression: `/^[a-zA-Z0-9,-]{22,250}$/`.
  1.         }
  2.         if (!$this->started && $this->saveHandler->isActive()) {
  3.             $this->loadSession();
  4.         } elseif (!$this->started) {
  5.             $this->start();
  6.         }
  7.         return $this->bags[$name];
  8.     }
  1.     /**
  2.      * {@inheritdoc}
  3.      */
  4.     public function getBag(string $name)
  5.     {
  6.         $bag $this->storage->getBag($name);
  7.         return method_exists($bag'getBag') ? $bag->getBag() : $bag;
  8.     }
  9.     /**
  1.      * @return AttributeBagInterface
  2.      */
  3.     protected function getSessionBag(): AttributeBagInterface
  4.     {
  5.         /** @var AttributeBagInterface $sessionBag */
  6.         $sessionBag $this->session->getBag(SessionConfigurator::ATTRIBUTE_BAG_ENVIRONMENT);
  7.         return $sessionBag;
  8.     }
  9. }
  1.         //if the session was not explicitly started in cli environment, do nothing
  2.         if ('cli' === php_sapi_name() && !$this->session->isStarted()) {
  3.             return;
  4.         }
  5.         $sessionBag $this->getSessionBag();
  6.         $this->customItems $sessionBag->get(self::SESSION_KEY_CUSTOM_ITEMS, []);
  7.         $this->userId $sessionBag->get(self::SESSION_KEY_USERIDself::USER_ID_NOT_SET);
  1.      *
  2.      * @return string
  3.      */
  4.     public function getCurrentAssortmentTenant()
  5.     {
  6.         $this->load();
  7.         return $this->currentAssortmentTenant;
  8.     }
  9.     /**
  1.      * @throws WorkerNotFoundException
  2.      */
  3.     protected function resolveTenantWorker(string $tenant null): WorkerInterface
  4.     {
  5.         if (null === $tenant) {
  6.             $tenant $this->environment->getCurrentAssortmentTenant();
  7.         }
  8.         if ($tenant) {
  9.             if (!array_key_exists($tenant$this->tenantWorkers)) {
  10.                 throw new WorkerNotFoundException(sprintf('Tenant "%s" doesn\'t exist'$tenant));
  1.         return $this->getCurrentTenantWorker()->getTenantConfig();
  2.     }
  3.     public function getCurrentTenantWorker(): WorkerInterface
  4.     {
  5.         return $this->resolveTenantWorker();
  6.     }
  7.     public function getProductListForCurrentTenant(): ProductListInterface
  8.     {
  9.         $tenantWorker $this->getCurrentTenantWorker();
  1.         return $this->resolveTenantWorker();
  2.     }
  3.     public function getProductListForCurrentTenant(): ProductListInterface
  4.     {
  5.         $tenantWorker $this->getCurrentTenantWorker();
  6.         return $tenantWorker->getProductList();
  7.     }
  8.     public function getProductListForTenant(string $tenant): ProductListInterface
IndexService->getProductListForCurrentTenant() in src/Controller/Products/categoryController.php (line 53)
  1.         $catId null;
  2.         if(!empty($request->get('url')) && empty($get_param)){
  3.             $catId = (string)$this->getCategoryId($request->get('url'));
  4.         }
  5.         $indexService $ecommerceFactory->getIndexService();
  6.         $productListing $indexService->getProductListForCurrentTenant();  
  7.         $productListing->addCondition("o_parentId != 74");    
  8.         if($query){
  9.             $productListing->addCondition("name LIKE '%{$query}%'"); 
  10.         }        
  11.         if(!empty($request->get('url')) && !empty($brand)){
in vendor/symfony/http-kernel/HttpKernel.php -> categoryProductAction (line 163)
  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 35)
  1. $kernel \Pimcore\Bootstrap::kernel();
  2. // reset current request - will be read from request stack from now on
  3. Tool::setCurrentRequest(null);
  4. $response $kernel->handle($request);
  5. $response->send();
  6. $kernel->terminate($request$response);

Logs

No log messages

Stack Trace

RuntimeException
RuntimeException:
Failed to start the session because headers have already been sent by "/var/www/goodycs/src/Controller/Products/categoryController.php" at line 523.

  at vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php:145
  at Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start()
     (vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php:352)
  at Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->getBag('ecommerceframework_environment')
     (vendor/symfony/http-foundation/Session/Session.php:261)
  at Symfony\Component\HttpFoundation\Session\Session->getBag('ecommerceframework_environment')
     (vendor/pimcore/pimcore/bundles/EcommerceFrameworkBundle/SessionEnvironment.php:129)
  at Pimcore\Bundle\EcommerceFrameworkBundle\SessionEnvironment->getSessionBag()
     (vendor/pimcore/pimcore/bundles/EcommerceFrameworkBundle/SessionEnvironment.php:67)
  at Pimcore\Bundle\EcommerceFrameworkBundle\SessionEnvironment->load()
     (vendor/pimcore/pimcore/bundles/EcommerceFrameworkBundle/Environment.php:241)
  at Pimcore\Bundle\EcommerceFrameworkBundle\Environment->getCurrentAssortmentTenant()
     (vendor/pimcore/pimcore/bundles/EcommerceFrameworkBundle/IndexService/IndexService.php:275)
  at Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\IndexService->resolveTenantWorker()
     (vendor/pimcore/pimcore/bundles/EcommerceFrameworkBundle/IndexService/IndexService.php:246)
  at Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\IndexService->getCurrentTenantWorker()
     (vendor/pimcore/pimcore/bundles/EcommerceFrameworkBundle/IndexService/IndexService.php:251)
  at Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\IndexService->getProductListForCurrentTenant()
     (src/Controller/Products/categoryController.php:53)
  at App\Controller\Products\categoryController->categoryProductAction(object(Request), object(Translator), object(Factory), object(ListHelper), object(Paginator))
     (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:35)