Commit Graph

15073 Commits

Author SHA1 Message Date
Jáchym Toušek
e0d3985a69 Fixed typo 2013-08-25 00:47:14 +02:00
Fabien Potencier
e71608339f merged branch bschussek/issue8789-regression (PR #8837)
This PR was merged into the 2.2 branch.

Discussion
----------

[Translation] Fixed regression: When only one rule is passed to transChoice(), this rule should be used

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

There was one regression introduced by #8789, namely when exactly one message is passed to `transChoice()`. Before, the following code was perfectly valid:

```php
$translator = new IdentityTranslator(new MessageSelector());

echo $translator->transChoice('There are two apples', 2, array('%count%' => 2));
```

This didn't fail, because internally, the locale `null` was passed to `MessageSelector`, which always returned the index `0` in that case.

Now, the user's locale is passed, and if the selector returns anything but `0`, an exception is thrown.

I removed this exception for the case that exactly one standard message (without explicit interval) is passed. In that case, this message is returned (just like from `trans()`). If the message key contains more than one message, or if the message has explicit intervals, the exception will still be thrown. See the tests for clarification.

A use case for why no exception should be thrown is validation:

```php
/**
 * @Assert\Length(min=2, minMessage="Please enter at least two characters")
 */
```

Commits
-------

2b3dcb9 [Translation] Grammar fix
0951b8d [Translation] Fixed regression: When only one rule is passed to transChoice(), this rule should be used
2013-08-24 17:28:40 +02:00
Fabien Potencier
fcb51c97dd merged branch bschussek/fix-locale-2.3 (PR #8847)
This PR was merged into the 2.3 branch.

Discussion
----------

[2.3][Locale] Fixed: StubLocale::setDefault() throws no exception when "en" is passed

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

Same as #8846 for 2.3+.

Commits
-------

e1f40f2 [Locale] Fixed: Locale::setDefault() throws no exception when "en" is passed
2013-08-24 17:27:17 +02:00
Fabien Potencier
b8381cdd62 Merge branch '2.2' into 2.3
* 2.2:
  [Locale] Fixed: StubLocale::setDefault() throws no exception when "en" is passed
  [Yaml] fixed embedded folded string parsing
  [Validator] fixed Boolean handling in XML constraint mappings (closes #5603)

Conflicts:
	src/Symfony/Component/Locale/Stub/StubLocale.php
	src/Symfony/Component/Locale/Tests/Stub/StubLocaleTest.php
2013-08-24 17:26:22 +02:00
Fabien Potencier
ebf3ceca56 merged branch bschussek/fix-locale-2.2 (PR #8846)
This PR was merged into the 2.2 branch.

Discussion
----------

[2.2][Locale] Fixed: StubLocale::setDefault() throws no exception when "en" is passed

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

This is necessary to fix `IntlTestHelper::requireIntl()` when ICU is not installed and the Icu component 1.0.0 is used instead. In that case, `IntlTestHelper::requireIntl()` calls `\Locale::setDefault('en')` and fails. Consequently, the Form component test cases are partially red when running without ICU installed.

This PR fixes that.

Commits
-------

d0faf55 [Locale] Fixed: StubLocale::setDefault() throws no exception when "en" is passed
2013-08-24 17:25:11 +02:00
Bernhard Schussek
e1f40f28c5 [Locale] Fixed: Locale::setDefault() throws no exception when "en" is passed
Conflicts:
	src/Symfony/Component/Locale/Stub/StubLocale.php
	src/Symfony/Component/Locale/Tests/Stub/StubLocaleTest.php
2013-08-24 16:32:55 +02:00
Bernhard Schussek
d0faf5531d [Locale] Fixed: StubLocale::setDefault() throws no exception when "en" is passed 2013-08-24 16:25:01 +02:00
Bernhard Schussek
2b3dcb9171 [Translation] Grammar fix 2013-08-24 14:29:44 +02:00
Fabien Potencier
b93d0cf58f merged branch pborreli/typos-sat (PR #8842)
This PR was merged into the master branch.

Discussion
----------

Fixed typos

Commits
-------

d37404c Fixed typos
2013-08-24 09:00:15 +02:00
Fabien Potencier
b2cbc67289 merged branch jfsimon/issue-8472 (PR #8841)
This PR was merged into the 2.2 branch.

Discussion
----------

[Yaml] fixed embedded folded string parsing

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #8779

Commits
-------

566d79c [Yaml] fixed embedded folded string parsing
2013-08-24 08:58:46 +02:00
Pascal Borreli
d37404ccf7 Fixed typos 2013-08-24 07:54:37 +01:00
Jean-François Simon
566d79c2f8 [Yaml] fixed embedded folded string parsing 2013-08-24 08:36:00 +02:00
Fabien Potencier
c3301dde87 merged branch fabpot/validator-xml-loader (PR #8831)
This PR was merged into the 2.2 branch.

Discussion
----------

[Validator] fixed Boolean handling in XML constraint mappings

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

ping @bschussek

Commits
-------

33b0a17 [Validator] fixed Boolean handling in XML constraint mappings (closes #5603)
2013-08-24 08:02:05 +02:00
Fabien Potencier
b9452e16b9 merged branch pborreli/patch-10 (PR #8839)
This PR was merged into the master branch.

Discussion
----------

Fixed typo

Commits
-------

bc6bd09 Fixed typo
2013-08-24 08:00:12 +02:00
Pascal Borreli
bc6bd09eb8 Fixed typo 2013-08-23 22:58:13 +01:00
Fabien Potencier
33b0a177b5 [Validator] fixed Boolean handling in XML constraint mappings (closes #5603) 2013-08-23 17:55:54 +02:00
Fabien Potencier
c3abd0c988 Merge branch '2.3'
* 2.3:
  fixed request format when forwarding a request
  [HttpKernel] added a comment to warn about possible inconsistencies
  added a functional test for locale handling in sub-requests
  Fixed issue #6932 - Inconsistent locale handling in subrequests
  fixed locale of sub-requests when explicitely set by the developer (refs #8821)

Conflicts:
	src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php
	src/Symfony/Component/HttpKernel/Fragment/RoutableFragmentRenderer.php
	src/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php
2013-08-23 17:34:04 +02:00
Fabien Potencier
6610a7c80e Merge branch '2.2' into 2.3
* 2.2:
  fixed request format when forwarding a request
  [HttpKernel] added a comment to warn about possible inconsistencies
  added a functional test for locale handling in sub-requests
  Fixed issue #6932 - Inconsistent locale handling in subrequests
  fixed locale of sub-requests when explicitely set by the developer (refs #8821)

Conflicts:
	src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php
2013-08-23 17:31:47 +02:00
Fabien Potencier
2165d5dffb merged branch fabpot/format-forward (PR #8829)
This PR was merged into the 2.2 branch.

Discussion
----------

fixed request format when forwarding a request

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

When calling forward() in a controller, the format is not the same as for the master request.

Commits
-------

7e87eb1 fixed request format when forwarding a request
2013-08-23 17:30:05 +02:00
Fabien Potencier
dac6e3dfc2 merged branch fabpot/fragment-locale (PR #8822)
This PR was merged into the 2.2 branch.

Discussion
----------

fixed locale management in sub-requests

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #6932, #5532, #8604
| License       | MIT
| Doc PR        | n/a

Same fix as #8821 but for `_locale`, and a rebase of #8604.

Commits
-------

7117328 [HttpKernel] added a comment to warn about possible inconsistencies
c4636e1 added a functional test for locale handling in sub-requests
05fdb12 Fixed issue #6932 - Inconsistent locale handling in subrequests
b3c3159 fixed locale of sub-requests when explicitely set by the developer (refs #8821)
2013-08-23 17:29:43 +02:00
Fabien Potencier
af58e54e49 merged branch fabpot/response-code-constants (PR #8820)
This PR was merged into the master branch.

Discussion
----------

[HttpFoundation] added constants for HTTP status code in Response

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

This adds constants for HTTP status code in Response. That's give the possibility to use constants instead of numbers in code.

These constants comes from FriendsOfSymfony/FOSRest but I think it is much better to keep them in Response as both the status texts and the constants should be synchronized.

ping @lsmith77

Commits
-------

0e14e1d [HttpFoundation] added constants for HTTP status code in Response
2013-08-23 17:28:41 +02:00
Fabien Potencier
1602746548 merged branch fabpot/tests-simplification (PR #8796)
This PR was merged into the master branch.

Discussion
----------

removed deps checks in unit tests

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

As Composer is now widely used in the PHP world, having to run composer install before running the test suite is expected. This also has the nice benefit of removing a bunch of code, making things easier to maintain (there is only one place to declare a dev dependency), and probably more.

see fabpot/Silex#626 where we did the same a while ago for Silex.

Commits
-------

de50621 removed deps checks in unit tests
2013-08-23 17:27:50 +02:00
Bernhard Schussek
0951b8de16 [Translation] Fixed regression: When only one rule is passed to transChoice(), this rule should be used 2013-08-23 17:24:14 +02:00
Fabien Potencier
5a5a94c509 Merge branch '2.3'
* 2.3:
  [Routing] fix phpdoc
  [Form] Extracted ReferencingArrayIterator out of VirtualFormAwareIterator
  [Yaml] Fix comment containing a colon on a scalar line being parsed as a hash.
  [Form] Added a test that ensures that setData() reacts to dynamic modifications of a form's children
  [Form] Removed exception in Button::setData(): setData() is now always called for all elements in the form tree during the initialization of the tree
  [Form] Removed call to deprecated method
  [Form] PropertyPathMapper::mapDataToForms() *always* calls setData() on every child to ensure that all *_DATA events were fired when the initialization phase is over (except for virtual forms)
  [Form] Removed superfluous reset() call
  [Form] Fixed: submit() reacts to dynamic modifications of the form children
2013-08-23 17:14:52 +02:00
Fabien Potencier
39f59b0fe9 Merge branch '2.2' into 2.3
* 2.2:
  [Routing] fix phpdoc
  [Yaml] Fix comment containing a colon on a scalar line being parsed as a hash.
2013-08-23 17:14:07 +02:00
Fabien Potencier
6f5a163991 merged branch bschussek/form-submit-2.3 (PR #8828)
This PR was merged into the 2.3 branch.

Discussion
----------

[Form][2.3] Fixed Form::submit() and Form::setData() to react to dynamic form modifications

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

ref #3767, #3768, #4548, #8748
cc @Burgov

This PR ensures that fields that are added during the submission process of a form are submitted as well. For example:

```php
$builder = $this->createFormBuilder()
    ->add('country', 'choice', ...)
    ->getForm();

$builder->get('country')->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
    $form = $event->getForm()->getParent();
    $country = $event->getForm()->getData();

    $form->add('province', 'choice', /* ... something with $country ... */);
});
```

Currently, the field "province" will not be submitted, because the submission loop uses `foreach`, which ignores changes in the underyling array.

Contrary to #8827 (for 2.2), this PR also allows dynamic modifications during `setData()`:

```php
$builder = $this->createFormBuilder()
    ->add('country', 'choice', ...)
    ->getForm();

$builder->get('country')->addEventListener(FormEvents::POST_SET_DATA, function (FormEvent $event) {
    $form = $event->getForm()->getParent();
    $country = $event->getData();

    $form->add('province', 'choice', /* ... something with $country ... */);
});
```

For 2.2, this fix is not possible, because it would require changing the signature `DataMapperInterface::mapDataToForms($data, array $forms)` to `DataMapperInterface::mapDataToForms($data, array &$forms)`, which would be a BC break. For 2.3, this change is not necessary (instead of an array we now pass an iterator, which is passed by reference anyway).

Additionally, this PR ensures that `setData()` is called on *every* element of a form (except those inheriting their parent data) when `setData()` is called on the root element (i.e., during initialization). Currently, when some of the intermediate nodes (e.g. embedded forms) are submitted with an empty value, `setData()` won't be called on the nodes below (i.e. the fields of the embedded form) until `get*Data()` is called on them. If `getData()` is *not* called before `createView()`, any effects of `*_DATA` event listeners attached to those fields will not be visible in the view.

Commits
-------

7a34d96 Merge branch 'form-submit-2.2' into form-submit-2.3
cd27e1f [Form] Extracted ReferencingArrayIterator out of VirtualFormAwareIterator
3cb8a80 [Form] Added a test that ensures that setData() reacts to dynamic modifications of a form's children
07d14e5 [Form] Removed exception in Button::setData(): setData() is now always called for all elements in the form tree during the initialization of the tree
b9a3770 [Form] Removed call to deprecated method
878e27c Merge branch 'form-submit-2.2' into form-submit-2.3
ccaaedf [Form] PropertyPathMapper::mapDataToForms() *always* calls setData() on every child to ensure that all *_DATA events were fired when the initialization phase is over (except for virtual forms)
19b483f [Form] Removed superfluous reset() call
5d60a4f Merge branch 'form-submit-2.2' into form-submit-2.3
00bc270 [Form] Fixed: submit() reacts to dynamic modifications of the form children
2013-08-23 17:13:57 +02:00
Fabien Potencier
599aab424a merged branch bschussek/form-submit-2.2 (PR #8827)
This PR was merged into the 2.2 branch.

Discussion
----------

[Form][2.2] Fixed Form::submit() to react to dynamic form modifications

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

ref #3767, #3768, #4548, #8748
cc @Burgov

This PR ensures that fields that are added during the submission process of a form are submitted as well. For example:

```php
$builder = $this->createFormBuilder()
    ->add('country', 'choice', ...)
    ->getForm();

$builder->get('country')->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
    $form = $event->getForm()->getParent();
    $country = $event->getForm()->getData();

    $form->add('province', 'choice', /* ... something with $country ... */);
});
```

Currently, the field "province" will not be submitted, because the submission loop uses `foreach`, which ignores changes in the underyling array.

Additionally, this PR ensures that `setData()` is called on *every* element of a form (except those inheriting their parent data) when `setData()` is called on the root element (i.e., during initialization). Currently, when some of the intermediate nodes (e.g. embedded forms) are submitted with an empty value, `setData()` won't be called on the nodes below (i.e. the fields of the embedded form) until `get*Data()` is called on them. If `getData()` is *not* called before `createView()`, any effects of `*_DATA` event listeners attached to those fields will not be visible in the view.

Commits
-------

cd27e1f [Form] Extracted ReferencingArrayIterator out of VirtualFormAwareIterator
ccaaedf [Form] PropertyPathMapper::mapDataToForms() *always* calls setData() on every child to ensure that all *_DATA events were fired when the initialization phase is over (except for virtual forms)
19b483f [Form] Removed superfluous reset() call
00bc270 [Form] Fixed: submit() reacts to dynamic modifications of the form children
2013-08-23 17:11:03 +02:00
Tobias Schultze
ee3cb88ec7 [Routing] fix phpdoc 2013-08-23 16:06:02 +02:00
Bernhard Schussek
7a34d96dcd Merge branch 'form-submit-2.2' into form-submit-2.3
Conflicts:
	src/Symfony/Component/Form/Util/VirtualFormAwareIterator.php
2013-08-23 13:18:39 +02:00
Bernhard Schussek
cd27e1facb [Form] Extracted ReferencingArrayIterator out of VirtualFormAwareIterator 2013-08-23 13:16:42 +02:00
Fabien Potencier
228ecb96d0 merged branch oscherler/yaml-comment-colon-fix (PR #8824)
This PR was squashed before being merged into the 2.2 branch (closes #8824).

Discussion
----------

[Yaml] Fix comment containing a colon on a scalar line being parsed as a hash.

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

Note: I only ran the Yaml Component tests.

This PR fixes a bug in YAML parsing where a comment containing a colon followed by a space, like this:

    foo # warning: this is a scalar with a comment, not a hash

was parsed as a hash, resulting in:

    array( 'foo # warning' => 'this is a scalar with a comment, not a hash' )

instead of:

    'foo'

Commits
-------

4563f1b [Yaml] Fix comment containing a colon on a scalar line being parsed as a hash.
2013-08-22 15:12:42 +02:00
Olivier
4563f1ba20 [Yaml] Fix comment containing a colon on a scalar line being parsed as a hash. 2013-08-22 15:12:42 +02:00
Fabien Potencier
7e87eb1fdf fixed request format when forwarding a request 2013-08-22 14:43:23 +02:00
Bernhard Schussek
3cb8a804f4 [Form] Added a test that ensures that setData() reacts to dynamic modifications of a form's children 2013-08-22 14:21:53 +02:00
Bernhard Schussek
07d14e5ff2 [Form] Removed exception in Button::setData(): setData() is now always called for all elements in the
form tree during the initialization of the tree
2013-08-22 14:19:04 +02:00
Bernhard Schussek
b9a37703a6 [Form] Removed call to deprecated method 2013-08-22 14:18:47 +02:00
Bernhard Schussek
878e27cd99 Merge branch 'form-submit-2.2' into form-submit-2.3
Conflicts:
	src/Symfony/Component/Form/Extension/Core/DataMapper/PropertyPathMapper.php
2013-08-22 14:12:19 +02:00
Bernhard Schussek
ccaaedfcbb [Form] PropertyPathMapper::mapDataToForms() *always* calls setData() on every child to ensure
that all *_DATA events were fired when the initialization phase is over (except for virtual forms)
2013-08-22 14:10:15 +02:00
Bernhard Schussek
19b483f2ea [Form] Removed superfluous reset() call 2013-08-22 13:38:57 +02:00
Bernhard Schussek
5d60a4fa0a Merge branch 'form-submit-2.2' into form-submit-2.3
Conflicts:
	src/Symfony/Component/Form/Form.php
	src/Symfony/Component/Form/Tests/AbstractFormTest.php
	src/Symfony/Component/Form/Tests/CompoundFormTest.php
	src/Symfony/Component/Form/Util/VirtualFormAwareIterator.php
2013-08-22 13:28:18 +02:00
Bernhard Schussek
00bc2708bc [Form] Fixed: submit() reacts to dynamic modifications of the form children 2013-08-22 13:20:04 +02:00
Fabien Potencier
7117328bd7 [HttpKernel] added a comment to warn about possible inconsistencies 2013-08-22 09:01:15 +02:00
Fabien Potencier
c4636e1252 added a functional test for locale handling in sub-requests 2013-08-22 08:57:44 +02:00
Charles Sarrazin
05fdb12ad9 Fixed issue #6932 - Inconsistent locale handling in subrequests
The fix consists in passing the locale in the controller reference,
inside the routablefragment renderer.
2013-08-22 08:57:23 +02:00
Fabien Potencier
b3c31593c7 fixed locale of sub-requests when explicitely set by the developer (refs #8821) 2013-08-22 08:48:41 +02:00
Fabien Potencier
167245c9c7 Merge branch '2.3'
* 2.3:
  [Locale] fixed build-data exit code in case of an error
  fixed request format of sub-requests when explicitely set by the developer (closes #8787)
  Sets _format attribute only if it wasn't set previously by the user.
  Exclude little words of 'ee' to 'oo' plural transformation
  fixed the format of the request used to render an exception
  Fix typo in the check_path validator
  added a missing use statement (closes #8808)
  fix for Process:isSuccessful()
  Include untrusted host in the exception message

Conflicts:
	src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php
	src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php
2013-08-22 08:44:20 +02:00
Fabien Potencier
8e1cb3e3ca Merge branch '2.2' into 2.3
* 2.2:
  [Locale] fixed build-data exit code in case of an error
  fixed request format of sub-requests when explicitely set by the developer (closes #8787)
  Sets _format attribute only if it wasn't set previously by the user.
  Exclude little words of 'ee' to 'oo' plural transformation
  fixed the format of the request used to render an exception
  Fix typo in the check_path validator
  added a missing use statement (closes #8808)
  fix for Process:isSuccessful()

Conflicts:
	UPGRADE-3.0.md
	src/Symfony/Component/Locale/Resources/data/build-data.php
2013-08-22 08:42:25 +02:00
Fabien Potencier
1ad64ee7a3 merged branch fabpot/inline-fragment-format (PR #8821)
This PR was merged into the 2.2 branch.

Discussion
----------

Sets _format attribute only if it wasn't set previously by the user

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

Commits
-------

9bb7a3d fixed request format of sub-requests when explicitely set by the developer (closes #8787)
fa35597 Sets _format attribute only if it wasn't set previously by the user.
2013-08-22 08:30:26 +02:00
Fabien Potencier
8ab368d104 merged branch fabpot/exception-format (PR #8819)
This PR was merged into the 2.2 branch.

Discussion
----------

[HttpKernel] Fix request _format duplication for HttpKernel's ExceptionListener

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #8777, #8778
| License       | MIT

This is a better fix for #8777.

Commits
-------

f946108 fixed the format of the request used to render an exception
2013-08-22 08:27:52 +02:00
Fabien Potencier
b72bc0b257 [Locale] fixed build-data exit code in case of an error
When passing a message to the exit() function, PHP returns 0 instead of
an error code.
2013-08-22 08:25:58 +02:00