-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Intl] Switch from json to php resources #34214
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
$symbolNamePairs = iterator_to_array($rootBundle['Currencies']); | ||
$symbolNamePairs = array_map(function ($pair) { | ||
return array_slice(iterator_to_array($pair), 0, 2); | ||
}, iterator_to_array($rootBundle['Currencies'])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to do this so that php generator doesn't dump the following invalid code:
'ESP' => [
0 => '₧',
1 => 'pesseta espanyola',
2 =>
ResourceBundle::__set_state(array(
)],
],
Json generator used to simply dump {}
.
We never use the third index. It's hardly ever present. If we dumped it it would like like this:
'ESP' => [
0 => '₧',
1 => 'pesseta espanyola',
2 => [
0 => '¤ #,##0.00',
1 => ',',
2 => '.',
],
],
07ccf85
to
85630ac
Compare
Question: Since from now on we'd be including php files directly, are there any security implications? The PhpBundleReader does this: return include $fileName; |
@jakzal not to me, all bundle read/write related infra is marked internal. All public classes with read access are final and use a fixed base path, e.g.: symfony/src/Symfony/Component/Intl/Timezones.php Lines 116 to 119 in 2c9a196
the directory traversal attack check is already in place, given the locale may be user provided:
|
Not if we don't allow user input to get there, ie no |
Note that we absolutely need to store the loaded data in a static variable. The reason is that we don't want to parse these files more than once when running test suites. |
@jakzal up to finish this one? |
|
@jakzal Why did you close it? |
It got out of date. I need a new one! |
Really cool PR! Would it be a lot of work to make a new PR? |
hello @jakzal what is the status of this PR? |
This PR was merged into the 5.3-dev branch. Discussion ---------- [Intl] Switch from json to php resources | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #23545 | License | MIT | Doc PR | - take over #34214 Commits ------- 24bfc3b [Intl] Switch from json to php resources
Benchmarks below were run on PHP 7.3.9. Average was taken for ten runs of each script.
Memory & Peak Memory was
2048kB
in all cases.