Skip to content

[Intl] Fixed a few bugs in TextBundleWriter #11906

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

Merged
merged 1 commit into from
Sep 15, 2014

Conversation

webmozart
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

See the included test cases for more information. This code was extracted from #9206.

@webmozart webmozart force-pushed the fix-textbundle-writer branch from a140d35 to 5d74d6e Compare September 11, 2014 17:11
/**
* Thrown when a method argument had an unexpected type.
*
* @since 2.5
Copy link
Member

Choose a reason for hiding this comment

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

The PR is on 2.3, so this is wrong.

@webmozart webmozart force-pushed the fix-textbundle-writer branch from 5d74d6e to 137d9ad Compare September 12, 2014 09:59
@webmozart
Copy link
Contributor Author

Updated.

$keys = array_keys($value);
$intKeys = count($value) === count(array_filter($keys, 'is_int')) &&
// check that the keys are 0-indexed and ascending
array_sum($keys) === array_sum(range(0, count($keys)-1));
Copy link
Member

Choose a reason for hiding this comment

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

this does not check that they are ascending actually.

The way we check this in other places in Symfony is using keys === range(0, count($keys) - 1)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed. I also added another test for this.

@webmozart webmozart force-pushed the fix-textbundle-writer branch from 137d9ad to 397ccb0 Compare September 12, 2014 10:38
$intValues = count($value) === count(array_filter($value, 'is_int'));

$keys = array_keys($value);
$intKeys = count($value) === count(array_filter($keys, 'is_int')) &&
Copy link
Member

Choose a reason for hiding this comment

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

this first condition is not needed. The second part is enough

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed

@webmozart webmozart force-pushed the fix-textbundle-writer branch from 397ccb0 to 7b4a35a Compare September 12, 2014 11:27
@webmozart
Copy link
Contributor Author

ping @symfony/deciders

@fabpot
Copy link
Member

fabpot commented Sep 15, 2014

👍

@webmozart webmozart merged commit 7b4a35a into symfony:2.3 Sep 15, 2014
webmozart added a commit that referenced this pull request Sep 15, 2014
This PR was merged into the 2.3 branch.

Discussion
----------

[Intl] Fixed a few bugs in TextBundleWriter

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

See the included test cases for more information. This code was extracted from #9206.

Commits
-------

7b4a35a [Intl] Fixed a few bugs in TextBundleWriter
webmozart added a commit that referenced this pull request Sep 30, 2014
This PR was merged into the 2.3 branch.

Discussion
----------

[Intl] Integrated ICU data into Intl component #1

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #11447, #10807
| License       | MIT
| Doc PR        | -

This PR is an alternative implementation to #11884. It depends on ~~#11906~~ and ~~#11907~~ being merged first (~~these are included in the diff until after a merge+rebase~~ merged+rebased now).

With this PR, the ICU component becomes obsolete. The ICU data is bundled with Intl in two different formats: JSON and the binary ICU resource bundle format (version 2) readable by PHP's `\ResourceBundle` class. For a performance comparison between the two, see my [benchmark](/webmozart/json-res-benchmark).

~~The data is contained in two zip files: json.zip (2.6MB) and rb-v2.zip (3.8MB). The handler~~

```php
\Symfony\Component\Intl\Composer\ScriptHandler::decompressData()
```

~~needs to be added as Composer hook and decompresses the data after install/update.~~

The data is included as text/binary now. Git takes care of the compression.

Before this PR can be merged, I would like to find out what the performance difference between the two formats is in real applications. For that, I need benchmarks from some real-life applications which use ICU data - e.g. in forms (language drop-downs, country selectors etc.) - for both the JSON and the binary data. You can force either format to be used by hard-coding the return value of `Intl::detectDataFormat()` to `Intl::JSON` and `Intl::RB_V2` respectively. I'll also try to create some more realistic benchmarks.

If JSON is not significantly slower/takes up significantly more memory than the binary format, we can drop the binary format altogether.

Commits
-------

be819c1 [Intl] Integrated ICU data into Intl component
@webmozart webmozart deleted the fix-textbundle-writer branch October 22, 2014 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants