Skip to content

Possible regression introduced by 7e87eb1fdfa #8917

@Taluu

Description

@Taluu

Hi,

In the commit 7e87eb1, which is fixing the request format when duplicating a Request object, you forcefully set the request format if the parent is already null.

The thing is, when forwarding in a controller to another controller (or maybe something, I haven't tested for another case yet), you may need to let the request format be null and unbiased.

Currently (brought by the commit 7e87eb1), if the request format is null, then it is set to an arbitrary default which is html... Which renders useless any attempt to get the "correct" request format in the forwarded controller, and the possibility to set a default.

This is easily manageable by doing a little hack before the forward :

<?php
use Syfmony\FrameworkBundle\Controller\Controller;

class MyController extends Controller
{
    public function myAction()
    {
        // ... stuff

        // little hack because of symfony/symfony's commit 7e87eb1fdf
        $request->getRequestFormat('json'); // json example. could be whatever except null

        $this->forward('Bundle:Action', ['param']);
    }
}

But still, I don't think this is what should be expected from the framework ; the request format, which is in my case handled by a view listener should be left as is and unbiased, even if it has a null value per default.

So, maybe this commit was made from a need, but still, I think this could be a possible regression.

Cheers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions