Failed to start the session because headers have already been sent by "/var/vhost/fasa/web/vendor/symfony/http-foundation/Response.php" at line 368. (500 Internal Server Error)

Symfony Exception

InvalidArgumentException RuntimeException

HTTP 500 Internal Server Error

Failed to start the session because headers have already been sent by "/var/vhost/fasa/web/vendor/symfony/http-foundation/Response.php" at line 368.

Exceptions 2

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.         // ok to try and start the session
  8.         if (!session_start()) {
  9.             throw new \RuntimeException('Failed to start the session.');
  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($name)
  5.     {
  6.         $bag $this->storage->getBag($name);
  7.         return method_exists($bag'getBag') ? $bag->getBag() : $bag;
  8.     }
  9.     /**
  1.      *
  2.      * Note that this method was added to help with IDE autocompletion.
  3.      */
  4.     private function getAttributeBag(): AttributeBagInterface
  5.     {
  6.         return $this->getBag($this->attributeName);
  7.     }
  8. }
  1.     /**
  2.      * {@inheritdoc}
  3.      */
  4.     public function has($name)
  5.     {
  6.         return $this->getAttributeBag()->has($name);
  7.     }
  8.     /**
  9.      * {@inheritdoc}
  10.      */
  1.     }
  2.     public function onKernelController(FilterControllerEvent $event)
  3.     {
  4.         $recintos $this->em->getRepository(RecintoFeria::class)->findAll();
  5.         if (!$event->getRequest()->getSession()->has('recinto') && count($recintos) > && false) {
  6.             $clientIP $event->getRequest()->getClientIp();
  7.             $subnet explode("."$clientIP);
  8.             $subnet[3] = '0';
  9.             $subnet implode("."$subnet);
  10.             $recinto current(array_filter($recintos, function($e) use($subnet) { return $e->getSubnet() == $subnet; }));
  1.         $this->called true;
  2.         $this->priority $dispatcher->getListenerPriority($eventName$this->listener);
  3.         $e $this->stopwatch->start($this->name'event_listener');
  4.         ($this->optimizedListener ?? $this->listener)($event$eventName$dispatcher);
  5.         if ($e->isStarted()) {
  6.             $e->stop();
  7.         }
  1.     {
  2.         foreach ($listeners as $listener) {
  3.             if ($event->isPropagationStopped()) {
  4.                 break;
  5.             }
  6.             $listener($event$eventName$this);
  7.         }
  8.     }
  9.     /**
  10.      * Sorts the internal list of listeners for the given event by priority.
  1.      * @param object     $event     The event object to pass to the event handlers/listeners
  2.      */
  3.     protected function callListeners(iterable $listenersstring $eventName$event)
  4.     {
  5.         if ($event instanceof Event) {
  6.             $this->doDispatch($listeners$eventName$event);
  7.             return;
  8.         }
  9.         $stoppable $event instanceof ContractsEvent || $event instanceof StoppableEventInterface;
  1.         } else {
  2.             $listeners $this->getListeners($eventName);
  3.         }
  4.         if ($listeners) {
  5.             $this->callListeners($listeners$eventName$event);
  6.         }
  7.         return $event;
  8.     }
  1.         try {
  2.             $this->beforeDispatch($eventName$event);
  3.             try {
  4.                 $e $this->stopwatch->start($eventName'section');
  5.                 try {
  6.                     $this->dispatcher->dispatch($event$eventName);
  7.                 } finally {
  8.                     if ($e->isStarted()) {
  9.                         $e->stop();
  10.                     }
  11.                 }
  1.         if (false === $controller $this->resolver->getController($request)) {
  2.             throw new NotFoundHttpException(sprintf('Unable to find the controller for path "%s". The route is wrongly configured.'$request->getPathInfo()));
  3.         }
  4.         $event = new ControllerEvent($this$controller$request$type);
  5.         $this->dispatcher->dispatch($eventKernelEvents::CONTROLLER);
  6.         $controller $event->getController();
  7.         // controller arguments
  8.         $arguments $this->argumentResolver->getArguments($request$controller);
  1.     public function handle(Request $request$type HttpKernelInterface::MASTER_REQUEST$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.         $exception $event->getThrowable();
  2.         $request $this->duplicateRequest($exception$event->getRequest());
  3.         try {
  4.             $response $event->getKernel()->handle($requestHttpKernelInterface::SUB_REQUESTfalse);
  5.         } catch (\Exception $e) {
  6.             $f FlattenException::createFromThrowable($e);
  7.             $this->logException($esprintf('Exception thrown when handling an exception (%s: %s at %s line %s)'$f->getClass(), $f->getMessage(), $e->getFile(), $e->getLine()));
  1.         $this->called true;
  2.         $this->priority $dispatcher->getListenerPriority($eventName$this->listener);
  3.         $e $this->stopwatch->start($this->name'event_listener');
  4.         ($this->optimizedListener ?? $this->listener)($event$eventName$dispatcher);
  5.         if ($e->isStarted()) {
  6.             $e->stop();
  7.         }
  1.     {
  2.         foreach ($listeners as $listener) {
  3.             if ($event->isPropagationStopped()) {
  4.                 break;
  5.             }
  6.             $listener($event$eventName$this);
  7.         }
  8.     }
  9.     /**
  10.      * Sorts the internal list of listeners for the given event by priority.
  1.      * @param object     $event     The event object to pass to the event handlers/listeners
  2.      */
  3.     protected function callListeners(iterable $listenersstring $eventName$event)
  4.     {
  5.         if ($event instanceof Event) {
  6.             $this->doDispatch($listeners$eventName$event);
  7.             return;
  8.         }
  9.         $stoppable $event instanceof ContractsEvent || $event instanceof StoppableEventInterface;
  1.         } else {
  2.             $listeners $this->getListeners($eventName);
  3.         }
  4.         if ($listeners) {
  5.             $this->callListeners($listeners$eventName$event);
  6.         }
  7.         return $event;
  8.     }
  1.         try {
  2.             $this->beforeDispatch($eventName$event);
  3.             try {
  4.                 $e $this->stopwatch->start($eventName'section');
  5.                 try {
  6.                     $this->dispatcher->dispatch($event$eventName);
  7.                 } finally {
  8.                     if ($e->isStarted()) {
  9.                         $e->stop();
  10.                     }
  11.                 }
  1.      * @throws \Exception
  2.      */
  3.     private function handleThrowable(\Throwable $eRequest $requestint $type): Response
  4.     {
  5.         $event = new ExceptionEvent($this$request$type$e);
  6.         $this->dispatcher->dispatch($eventKernelEvents::EXCEPTION);
  7.         // a listener might have replaced the exception
  8.         $e $event->getThrowable();
  9.         if (!$event->hasResponse()) {
  1.     {
  2.         if (!$request $request ?: $this->requestStack->getMasterRequest()) {
  3.             throw $exception;
  4.         }
  5.         $response $this->handleThrowable($exception$requestself::MASTER_REQUEST);
  6.         $response->sendHeaders();
  7.         $response->sendContent();
  8.         $this->terminate($request$response);
  1.                         if ($hasRun) {
  2.                             throw $e;
  3.                         }
  4.                         $hasRun true;
  5.                         $kernel->terminateWithException($e$request);
  6.                     };
  7.                 }
  8.             } elseif ($event instanceof ConsoleEvent && $app $event->getCommand()->getApplication()) {
  9.                 $output $event->getOutput();
  10.                 if ($output instanceof ConsoleOutputInterface) {
in /var/vhost/fasa/web/vendor/symfony/error-handler/ErrorHandler.php :: Symfony\Component\HttpKernel\EventListener\{closure} (line 601)
  1.             $this->exceptionHandler null;
  2.         }
  3.         try {
  4.             if (null !== $exceptionHandler) {
  5.                 return $exceptionHandler($exception);
  6.             }
  7.             $handlerException $handlerException ?: $exception;
  8.         } catch (\Throwable $handlerException) {
  9.         }
  10.         if ($exception === $handlerException && null === $this->exceptionHandler) {
ErrorHandler->handleException()

InvalidArgumentException

The Swiftmailer URL "gmail://a:blocalhost" is not valid.

  1.             'stream_options' => [],
  2.         ];
  3.         if (isset($options['url'])) {
  4.             if (false === $parts parse_url($options['url'])) {
  5.                 throw new \InvalidArgumentException(sprintf('The Swiftmailer URL "%s" is not valid.'$options['url']));
  6.             }
  7.             if (isset($parts['scheme'])) {
  8.                 $options['transport'] = $parts['scheme'];
  9.             }
  10.             if (isset($parts['user'])) {
  1.      *
  2.      * @throws \InvalidArgumentException if the scheme is not a built-in Swiftmailer transport
  3.      */
  4.     public static function createTransport(array $optionsRequestContext $requestContext null, \Swift_Events_EventDispatcher $eventDispatcher)
  5.     {
  6.         $options = static::resolveOptions($options);
  7.         self::validateConfig($options);
  8.         if ('smtp' === $options['transport']) {
  9.             $smtpAuthHandler = new \Swift_Transport_Esmtp_AuthHandler([
  10.                 new \Swift_Transport_Esmtp_Auth_CramMd5Authenticator(),
  1.         include_once \dirname(__DIR__4).'/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport.php';
  2.         include_once \dirname(__DIR__4).'/vendor/symfony/swiftmailer-bundle/DependencyInjection/SwiftmailerTransportFactory.php';
  3.         include_once \dirname(__DIR__4).'/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php';
  4.         include_once \dirname(__DIR__4).'/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php';
  5.         return $this->services['swiftmailer.mailer.default.transport.real'] = \Symfony\Bundle\SwiftmailerBundle\DependencyInjection\SwiftmailerTransportFactory::createTransport(['transport' => 'smtp''url' => $this->getEnv('MAILER_URL'), 'username' => NULL'password' => NULL'host' => 'localhost''port' => NULL'timeout' => 30'source_ip' => NULL'local_domain' => NULL'encryption' => NULL'auth_mode' => NULL'command' => '/usr/sbin/sendmail -t -i''stream_options' => []], ($this->privates['router.request_context'] ?? $this->getRouter_RequestContextService()), ($this->privates['swiftmailer.mailer.default.transport.eventdispatcher'] ?? ($this->privates['swiftmailer.mailer.default.transport.eventdispatcher'] = new \Swift_Events_SimpleEventDispatcher())));
  6.     }
  7.     /**
  8.      * Gets the public 'swiftmailer.transport' shared service.
  9.      *
in /var/vhost/fasa/web/vendor/symfony/dependency-injection/Container.php -> getSwiftmailer_Mailer_Default_Transport_RealService (line 257)
  1.         try {
  2.             if (isset($this->fileMap[$id])) {
  3.                 return /* self::IGNORE_ON_UNINITIALIZED_REFERENCE */ === $invalidBehavior null $this->load($this->fileMap[$id]);
  4.             } elseif (isset($this->methodMap[$id])) {
  5.                 return /* self::IGNORE_ON_UNINITIALIZED_REFERENCE */ === $invalidBehavior null $this->{$this->methodMap[$id]}();
  6.             }
  7.         } catch (\Exception $e) {
  8.             unset($this->services[$id]);
  9.             throw $e;
  1.      */
  2.     public function get($id$invalidBehavior /* self::EXCEPTION_ON_INVALID_REFERENCE */ 1)
  3.     {
  4.         $service $this->services[$id]
  5.             ?? $this->services[$id $this->aliases[$id] ?? $id]
  6.             ?? ('service_container' === $id $this : ($this->factories[$id] ?? [$this'make'])($id$invalidBehavior));
  7.         if (!\is_object($service) && null !== $service) {
  8.             @trigger_error(sprintf('Non-object services are deprecated since Symfony 4.4, please fix the "%s" service which is of type "%s" right now.'$id, \gettype($service)), \E_USER_DEPRECATED);
  9.         }
  1.                     $transport $mailer->getTransport();
  2.                     if ($transport instanceof \Swift_Transport_SpoolTransport) {
  3.                         $spool $transport->getSpool();
  4.                         if ($spool instanceof \Swift_MemorySpool) {
  5.                             try {
  6.                                 $spool->flushQueue($this->container->get(sprintf('swiftmailer.mailer.%s.transport.real'$name)));
  7.                             } catch (\Swift_TransportException $exception) {
  8.                                 if (null !== $this->logger) {
  9.                                     $this->logger->error(sprintf('Exception occurred while flushing email queue: %s'$exception->getMessage()));
  10.                                 }
  11.                             }
  1.         $this->called true;
  2.         $this->priority $dispatcher->getListenerPriority($eventName$this->listener);
  3.         $e $this->stopwatch->start($this->name'event_listener');
  4.         ($this->optimizedListener ?? $this->listener)($event$eventName$dispatcher);
  5.         if ($e->isStarted()) {
  6.             $e->stop();
  7.         }
  1.     {
  2.         foreach ($listeners as $listener) {
  3.             if ($event->isPropagationStopped()) {
  4.                 break;
  5.             }
  6.             $listener($event$eventName$this);
  7.         }
  8.     }
  9.     /**
  10.      * Sorts the internal list of listeners for the given event by priority.
  1.      * @param object     $event     The event object to pass to the event handlers/listeners
  2.      */
  3.     protected function callListeners(iterable $listenersstring $eventName$event)
  4.     {
  5.         if ($event instanceof Event) {
  6.             $this->doDispatch($listeners$eventName$event);
  7.             return;
  8.         }
  9.         $stoppable $event instanceof ContractsEvent || $event instanceof StoppableEventInterface;
  1.         } else {
  2.             $listeners $this->getListeners($eventName);
  3.         }
  4.         if ($listeners) {
  5.             $this->callListeners($listeners$eventName$event);
  6.         }
  7.         return $event;
  8.     }
  1.         try {
  2.             $this->beforeDispatch($eventName$event);
  3.             try {
  4.                 $e $this->stopwatch->start($eventName'section');
  5.                 try {
  6.                     $this->dispatcher->dispatch($event$eventName);
  7.                 } finally {
  8.                     if ($e->isStarted()) {
  9.                         $e->stop();
  10.                     }
  11.                 }
  1.     /**
  2.      * {@inheritdoc}
  3.      */
  4.     public function terminate(Request $requestResponse $response)
  5.     {
  6.         $this->dispatcher->dispatch(new TerminateEvent($this$request$response), KernelEvents::TERMINATE);
  7.     }
  8.     /**
  9.      * @internal
  10.      */
  1.         if (false === $this->booted) {
  2.             return;
  3.         }
  4.         if ($this->getHttpKernel() instanceof TerminableInterface) {
  5.             $this->getHttpKernel()->terminate($request$response);
  6.         }
  7.     }
  8.     /**
  9.      * {@inheritdoc}
Kernel->terminate() in /var/vhost/fasa/web/public/index.php (line 27)
  1. $kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
  2. $request Request::createFromGlobals();
  3. $response $kernel->handle($request);
  4. $response->send();
  5. $kernel->terminate($request$response);

Stack Traces 2

[2/2] RuntimeException

RuntimeException:
Failed to start the session because headers have already been sent by "/var/vhost/fasa/web/vendor/symfony/http-foundation/Response.php" at line 368.

  at /var/vhost/fasa/web/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php:152
  at Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start()
     (/var/vhost/fasa/web/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php:323)
  at Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->getBag()
     (/var/vhost/fasa/web/vendor/symfony/http-foundation/Session/Session.php:251)
  at Symfony\Component\HttpFoundation\Session\Session->getBag()
     (/var/vhost/fasa/web/vendor/symfony/http-foundation/Session/Session.php:273)
  at Symfony\Component\HttpFoundation\Session\Session->getAttributeBag()
     (/var/vhost/fasa/web/vendor/symfony/http-foundation/Session/Session.php:65)
  at Symfony\Component\HttpFoundation\Session\Session->has()
     (/var/vhost/fasa/web/src/EventListener/RequestListener.php:32)
  at App\EventListener\RequestListener->onKernelController()
     (/var/vhost/fasa/web/vendor/symfony/event-dispatcher/Debug/WrappedListener.php:126)
  at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke()
     (/var/vhost/fasa/web/vendor/symfony/event-dispatcher/EventDispatcher.php:264)
  at Symfony\Component\EventDispatcher\EventDispatcher->doDispatch()
     (/var/vhost/fasa/web/vendor/symfony/event-dispatcher/EventDispatcher.php:239)
  at Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
     (/var/vhost/fasa/web/vendor/symfony/event-dispatcher/EventDispatcher.php:73)
  at Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
     (/var/vhost/fasa/web/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:168)
  at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch()
     (/var/vhost/fasa/web/vendor/symfony/http-kernel/HttpKernel.php:146)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw()
     (/var/vhost/fasa/web/vendor/symfony/http-kernel/HttpKernel.php:80)
  at Symfony\Component\HttpKernel\HttpKernel->handle()
     (/var/vhost/fasa/web/vendor/symfony/http-kernel/EventListener/ErrorListener.php:60)
  at Symfony\Component\HttpKernel\EventListener\ErrorListener->onKernelException()
     (/var/vhost/fasa/web/vendor/symfony/event-dispatcher/Debug/WrappedListener.php:126)
  at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke()
     (/var/vhost/fasa/web/vendor/symfony/event-dispatcher/EventDispatcher.php:264)
  at Symfony\Component\EventDispatcher\EventDispatcher->doDispatch()
     (/var/vhost/fasa/web/vendor/symfony/event-dispatcher/EventDispatcher.php:239)
  at Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
     (/var/vhost/fasa/web/vendor/symfony/event-dispatcher/EventDispatcher.php:73)
  at Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
     (/var/vhost/fasa/web/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:168)
  at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch()
     (/var/vhost/fasa/web/vendor/symfony/http-kernel/HttpKernel.php:219)
  at Symfony\Component\HttpKernel\HttpKernel->handleThrowable()
     (/var/vhost/fasa/web/vendor/symfony/http-kernel/HttpKernel.php:112)
  at Symfony\Component\HttpKernel\HttpKernel->terminateWithException()
     (/var/vhost/fasa/web/vendor/symfony/http-kernel/EventListener/DebugHandlersListener.php:129)
  at Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::Symfony\Component\HttpKernel\EventListener\{closure}()
     (/var/vhost/fasa/web/vendor/symfony/error-handler/ErrorHandler.php:601)
  at Symfony\Component\ErrorHandler\ErrorHandler->handleException()                

[1/2] InvalidArgumentException

InvalidArgumentException:
The Swiftmailer URL "gmail://a:blocalhost" is not valid.

  at /var/vhost/fasa/web/vendor/symfony/swiftmailer-bundle/DependencyInjection/SwiftmailerTransportFactory.php:99
  at Symfony\Bundle\SwiftmailerBundle\DependencyInjection\SwiftmailerTransportFactory::resolveOptions()
     (/var/vhost/fasa/web/vendor/symfony/swiftmailer-bundle/DependencyInjection/SwiftmailerTransportFactory.php:30)
  at Symfony\Bundle\SwiftmailerBundle\DependencyInjection\SwiftmailerTransportFactory::createTransport()
     (/var/vhost/fasa/web/var/cache/dev/ContainerZm6s6AM/srcApp_KernelDevDebugContainer.php:4988)
  at ContainerZm6s6AM\srcApp_KernelDevDebugContainer->getSwiftmailer_Mailer_Default_Transport_RealService()
     (/var/vhost/fasa/web/vendor/symfony/dependency-injection/Container.php:257)
  at Symfony\Component\DependencyInjection\Container->make()
     (/var/vhost/fasa/web/vendor/symfony/dependency-injection/Container.php:231)
  at Symfony\Component\DependencyInjection\Container->get()
     (/var/vhost/fasa/web/vendor/symfony/swiftmailer-bundle/EventListener/EmailSenderListener.php:61)
  at Symfony\Bundle\SwiftmailerBundle\EventListener\EmailSenderListener->onTerminate()
     (/var/vhost/fasa/web/vendor/symfony/event-dispatcher/Debug/WrappedListener.php:126)
  at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke()
     (/var/vhost/fasa/web/vendor/symfony/event-dispatcher/EventDispatcher.php:264)
  at Symfony\Component\EventDispatcher\EventDispatcher->doDispatch()
     (/var/vhost/fasa/web/vendor/symfony/event-dispatcher/EventDispatcher.php:239)
  at Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
     (/var/vhost/fasa/web/vendor/symfony/event-dispatcher/EventDispatcher.php:73)
  at Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
     (/var/vhost/fasa/web/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:168)
  at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch()
     (/var/vhost/fasa/web/vendor/symfony/http-kernel/HttpKernel.php:100)
  at Symfony\Component\HttpKernel\HttpKernel->terminate()
     (/var/vhost/fasa/web/vendor/symfony/http-kernel/Kernel.php:166)
  at Symfony\Component\HttpKernel\Kernel->terminate()
     (/var/vhost/fasa/web/public/index.php:27)