Skip to content

[FileValidator] Format file size in validation message according to binaryFormat option #27970

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

Conversation

jfredon
Copy link
Contributor

@jfredon jfredon commented Jul 16, 2018

Q A
Branch? 2.8 up to master
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #27682
License MIT
Doc PR

The binaryFormat option of the constraint is not taken into account if the maxsize limit is defined by the php configuration files.
This patch correct this inconsistent behavior.

If the binaryOption is not set, the unit of measurement used remains in binary because it’s the unit used in php configuration files.

@jfredon jfredon changed the base branch from master to 2.8 July 16, 2018 20:49
@jfredon
Copy link
Contributor Author

jfredon commented Jul 16, 2018

I'm not very proud of how i changed the tests, i think i used a dirty trick.
The FileValidator::factorizeSizes() method is private and so difficult to use in test.
What is the best way of doing this sort of thing ?
Should i change the visibility of the method? Maybe extract the method in a helper object?

@jfredon jfredon force-pushed the issue-27682_b2.8-FileValidator-message-binaryFormat branch 2 times, most recently from f48001d to e34d9a3 Compare July 16, 2018 21:14
@@ -57,6 +57,16 @@ protected function tearDown()
$this->file = null;
}

// Allows the invocation of a private method
public function invokeMethod($object, $methodName, $params = array())
Copy link
Member

Choose a reason for hiding this comment

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

let's do this inline, no need for a method when it is used only once here

@nicolas-grekas nicolas-grekas added this to the 2.8 milestone Jul 23, 2018
@jfredon jfredon force-pushed the issue-27682_b2.8-FileValidator-message-binaryFormat branch from e34d9a3 to 8c7c023 Compare July 23, 2018 21:31
@jfredon jfredon changed the title [WIP][FileValidator] Format file size in validation message according to binaryFormat option [FileValidator] Format file size in validation message according to binaryFormat option Jul 29, 2018
@jfredon jfredon force-pushed the issue-27682_b2.8-FileValidator-message-binaryFormat branch from 8c7c023 to 45e5084 Compare July 29, 2018 18:06
@jfredon jfredon force-pushed the issue-27682_b2.8-FileValidator-message-binaryFormat branch from 45e5084 to 0edbbd3 Compare July 29, 2018 18:16
@fabpot
Copy link
Member

fabpot commented Sep 4, 2018

Thank you @jfredon.

@fabpot fabpot merged commit 0edbbd3 into symfony:2.8 Sep 4, 2018
fabpot added a commit that referenced this pull request Sep 4, 2018
…ording to binaryFormat option (jfredon)

This PR was merged into the 2.8 branch.

Discussion
----------

[FileValidator] Format file size in validation message according to binaryFormat option

| Q             | A
| ------------- | ---
| Branch?       | 2.8 up to master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #27682
| License       | MIT
| Doc PR        |

The binaryFormat option of the constraint is not taken into account if the maxsize limit is defined by the php configuration files.
This patch correct this inconsistent behavior.

If the binaryOption is not set, the unit of measurement used remains in binary because it’s the unit used in php configuration files.

Commits
-------

0edbbd3 Format file size in validation message according to binaryFormat option
This was referenced Sep 30, 2018
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.

4 participants