RuntimeException: Failed to start the session because headers have already been sent by ... rest_api_authentication.install

Created on 25 January 2023, almost 2 years ago
Updated 12 December 2023, 11 months ago

Problem/Motivation

When I try to enable this module I' m getting this error.

RuntimeException: Failed to start the session because headers have already been sent by "/.../web/modules/contrib/rest_api_authentication/rest_api_authentication.install" at line 1. in Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start() (line 152 of /.../vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php)

Steps to reproduce

On Drupal 9.5.2 with PHP 8.1.14 (same with PHP 7.4.33)

  1. Install this module with composer
  2. Try to enable the module from drupal Web Interface (Admin)
🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇬🇷Greece ath.galanis

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @ath.galanis
  • 🇮🇳India arsh244

    Hi there, I just tried to reproduce the error using the steps you mentioned but everything seemed to be working fine on my end. Can you please install the latest version of the module(2.0.5) and test again? Please let me know whether the issue persists

  • 🇨🇦Canada Shane Birley

    Doing a fresh install of the module both via Composer and manual. I receive the same error. I uninstalled the module, installed a fresh copy of Drupal and installed this module by itself -- same error.

    Uncaught PHP Exception RuntimeException: "Failed to start the session because headers have already been sent by "/home/www/modules/rest_api_authentication/rest_api_authentication.install" at line 1." at /home/www/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php line 152
    
    RuntimeException: Failed to start the session because headers have already been sent by "/home/www/modules/rest_api_authentication/rest_api_authentication.install" at line 1. in /home/www/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php on line 152 #0 /home/www/core/lib/Drupal/Core/Session/SessionManager.php(162): Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start()
    #1 /home/www/core/lib/Drupal/Core/Session/SessionManager.php(193): Drupal\Core\Session\SessionManager->startNow()
    #2 /home/www/vendor/symfony/http-foundation/Session/Session.php(191): Drupal\Core\Session\SessionManager->save()
    #3 /home/www/core/lib/Drupal/Core/StackMiddleware/Session.php(61): Symfony\Component\HttpFoundation\Session\Session->save()
    #4 /home/www/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #5 /home/www/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #6 /home/www/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #7 /home/www/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #8 /home/www/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #9 /home/www/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #10 /home/www/core/lib/Drupal/Core/DrupalKernel.php(713): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #11 /home/www/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
    #12 {main}
  • 🇨🇦Canada Shane Birley

    Just another note, Drupal believes the modules is indeed installed but the configuration pages are blank and return 404 errors.

  • 🇨🇦Canada Shane Birley

    And to clarify, this is on the latest version 2.0.6.

  • 🇮🇳India arsh244

    Hi @Shane, thanks for sharing the error trace. I just checked the code and it seems like there is an additional line before the php tag for the .install file. As I am not able to reproduce the issue on my environment, can you please test the latest module (version: 2.0.7) and let me know if the issue still persists.
    Thanks in advance.

  • 🇨🇿Czech Republic skutova.mir

    Hi,

    there is the same issue with the newest version 2.0.8. Blank line before opening <?php tags in install file. Removing this line solves the problem.

  • 🇮🇳India arsh244

    Hi @skutova.mir, thank you for pointing out the issue. I have made the said fixes and released an update of the module. As I am not able to reproduce the exact issue on my end, can you please test it out once just to confirm if the issue is resolved?

  • Status changed to Needs review 11 months ago
Production build 0.71.5 2024