Uploaded image for project: 'eZ Platform Enterprise Edition'
  1. eZ Platform Enterprise Edition
  2. EZEE-3186

Controller returning StreamedResponse will result in FatalThrowableError

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: 3.0.5, 2.5.11
    • Component/s: Page Builder
    • Labels:
      None
    • Environment:

      Controller returning StreamedResponse will result in FatalThrowableError

      Description

      When Controller returns StreamedResponse, InjectCrossOriginHelperSubscriber will throw FatalThrowableError.

      Type error: stripos() expects parameter 1 to be string, bool given
      

      Steps to reproduce
      1. Clean installation of eZ Platform 2.5
      2. Create a new src/AppBundle/Controller/TestController:

      <?php
      
      namespace AppBundle\Controller;
      
      use Symfony\Component\HttpFoundation\StreamedResponse;
      
      class TestController
      {
          public function downloadAction()
          {
              $response = new StreamedResponse();
              $response->setCallback(function () {
                  var_dump('Hello World');
                  flush();
                  var_dump('Hello World');
                  flush();
              });
              $response->send();
      
              return $response;
          }
      }
      
      

      3. Add route for it - in app/config/routing.yml add at the begnining:

      test:
          path: /test
          defaults: { _controller: AppBundle:Test:download }
      

      4. In your browser go to http://<your_project>/test.
      5. Check logs/profiler for the request

      Result

      FatalThrowableError
      Type error: stripos() expects parameter 1 to be string, bool given
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            mateusz.bieniek@ez.no Mateusz Bieniek
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: