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

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

Conversation

Projects
None yet
4 participants
@jfredon
Copy link
Contributor

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 Jul 16, 2018

@jfredon

This comment has been minimized.

Copy link
Contributor Author

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 jfredon:issue-27682_b2.8-FileValidator-message-binaryFormat branch 2 times, most recently from f48001d to e34d9a3 Jul 16, 2018

@@ -57,6 +57,16 @@ protected function tearDown()
$this->file = null;
}
// Allows the invocation of a private method
public function invokeMethod($object, $methodName, $params = array())

This comment has been minimized.

Copy link
@nicolas-grekas

nicolas-grekas Jul 23, 2018

Member

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 jfredon:issue-27682_b2.8-FileValidator-message-binaryFormat branch from e34d9a3 to 8c7c023 Jul 23, 2018

@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 jfredon:issue-27682_b2.8-FileValidator-message-binaryFormat branch from 8c7c023 to 45e5084 Jul 29, 2018

@jfredon jfredon force-pushed the jfredon:issue-27682_b2.8-FileValidator-message-binaryFormat branch from 45e5084 to 0edbbd3 Jul 29, 2018

@fabpot

fabpot approved these changes Sep 4, 2018

@fabpot

This comment has been minimized.

Copy link
Member

commented Sep 4, 2018

Thank you @jfredon.

@fabpot fabpot merged commit 0edbbd3 into symfony:2.8 Sep 4, 2018

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
fabbot.io Your code looks good.
Details

fabpot added a commit that referenced this pull request Sep 4, 2018

bug #27970 [FileValidator] Format file size in validation message acc…
…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
You can’t perform that action at this time.