Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Serializer] Fix decoding attribute that contains many digits#22333

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
vlastv wants to merge3 commits intosymfony:2.7fromvlastv:patch-4
Closed

[Serializer] Fix decoding attribute that contains many digits#22333

vlastv wants to merge3 commits intosymfony:2.7fromvlastv:patch-4

Conversation

@vlastv
Copy link
Contributor

@vlastvvlastv commentedApr 7, 2017
edited
Loading

QA
Branch?2.7
Bug fix?yes
New feature?no
BC breaks?yes
Deprecations?no
Tests pass?yes
Fixed tickets#22329
LicenseMIT

@nicolas-grekasnicolas-grekas added this to the2.7 milestoneApr 7, 2017
}else {
$data['@'.$attr->nodeName] =$attr->nodeValue;
}
$data['@'.$attr->nodeName] =$attr->nodeValue;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a BC break in case someone relies on the type of the decoded data (this could happen easily with PHP7 et strict types).

Maybe you could check if the cast toint loses information and keep a string only in this case.

sstok reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@jvasseur I changed in PR description BC break flag.
If checking possibility cast, thenonly positive integer will return as int and all others as string.
I think this behavior is wrong.

Copy link
Contributor

Choose a reason for hiding this comment

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

https://3v4l.org/fRfCH

'-321312' is properly converted to -321312.

Copy link
ContributorAuthor

@vlastvvlastvApr 7, 2017
edited
Loading

Choose a reason for hiding this comment

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

@sstok this is a BC break, earlier would return as a stringctype_digit('-321312') === false

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

My comment about positive integer actual only if need save BC.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

on different data in attribute you get different type, in PHP 7 with strict_types=1 this can create exception;

Copy link
Contributor

Choose a reason for hiding this comment

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

-321312 would have been converted to a string. Which technically is a bug, the double cast checking ensures it's converted to an integer ONLY when the actual result would not change.

(string) ((int)'-321312') === '-321312'.
https://3v4l.org/mvlQN

dunglas reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@sstok method must return only one data type

Copy link
Contributor

Choose a reason for hiding this comment

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

This method always returns an array 😛 the values of the array vary.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I propose to open a second PR with your implementation.
You will also have a break BC

@vlastvvlastv changed the titleFix decoding attribute that contains many digits[Serializer] Fix decoding attribute that contains many digitsApr 7, 2017
@dunglas
Copy link
Member

dunglas commentedApr 19, 2017
edited
Loading

I suggest to return afloat instead of an int only for large numbers. It will be consistent with the behavior of the JSON encoder behavior:https://3v4l.org/O5gST

@dunglas
Copy link
Member

By the way the current handling of negative integers is faulty and should be considered as a bug.

@vlastv
Copy link
ContributorAuthor

@dunglas we can not know whether a string is a number in fact, or it is a random circumstance.
Suppose that as a result of base64_encode, a line containing only numbers ...

fabpot added a commit that referenced this pull requestApr 23, 2017
…s handling (dunglas)This PR was merged into the 2.7 branch.Discussion----------[Serializer] XmlEncoder: fix negative int and large numbers handling| Q             | A| ------------- | ---| Branch?       | 2.7 <!-- see comment below -->| Bug fix?      | yes| New feature?  | no <!-- don't forget updating src/**/CHANGELOG.md files -->| BC breaks?    | no| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->| Tests pass?   | yes| Fixed tickets |#22329,#22333 <!-- #-prefixed issue number(s), if any -->| License       | MIT| Doc PR        | n/aAlternative to#22333.* Negative integers are now handled* Float are now handled* Large numbers are converted to float (as the `JsonEncoder` and native PHP functions like `ceil` do)@vlastv, I've adapted your test. Can you check if it fixes your problem?Commits-------1eeadb0 [Serializer] XmlEncoder: fix negative int and large numbers handling
@fabpotfabpot closed thisApr 23, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

2 more reviewers

@jvasseurjvasseurjvasseur left review comments

@sstoksstoksstok left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

2.7

Development

Successfully merging this pull request may close these issues.

7 participants

@vlastv@dunglas@jvasseur@sstok@fabpot@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp