Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes sprintf(): Too few arguments in form transformer #36907

Merged
merged 1 commit into from May 30, 2020
Merged

Fixes sprintf(): Too few arguments in form transformer #36907

merged 1 commit into from May 30, 2020

Conversation

pedrocasado
Copy link
Contributor

Similar to: #29482

Q A
Branch? 3.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets none
License MIT
Doc PR none

Fixes the form reverse transformation when the method viewToNorm is called within a value with the character %:

Before : "sprintf(): Too few arguments"

After : Form reverse transformation works.

Reference : http://php.net/manual/function.sprintf.php

@xabbuh
Copy link
Member

xabbuh commented May 22, 2020

Can we add a test case to prevent future regressions (IIRC this was done recently to satisfy fabbot.io)?

@ro0NL
Copy link
Contributor

ro0NL commented May 25, 2020

Hi @pedrocasado can you also have a look at #36954 maybe :)

Copy link
Member

@Tobion Tobion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like most (all?) of this was already fixed, e.g. in #36684
You need to rebase.

@Tobion
Copy link
Member

Tobion commented May 26, 2020

Please add a test as suggested by @xabbuh for at least one case like the Form transformation.

@pedrocasado
Copy link
Contributor Author

@Tobion , can you give me some guidance? do you think this test is enough?

public function testDataTransformationEscapesValueCorrectlyInException()
{
    $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
    $this->expectExceptionMessage('Unable to transform data for property path "name": No mapping for value "90%"');
    $model = new FixedDataTransformer([
        'default' => 'foo',
    ]);
    $view = new FixedDataTransformer([
        'foo' => 'bar',
    ]);

    $config = new FormConfigBuilder('name', null, $this->dispatcher);
    $config->addViewTransformer($view);
    $config->addModelTransformer($model);
    $config->setData('90%');
    $form = new Form($config);

    $form->getData();
}

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(let's skip adding tests for this...)

@nicolas-grekas
Copy link
Member

Thank you @pedrocasado.

@nicolas-grekas nicolas-grekas merged commit e8beef4 into symfony:3.4 May 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants