Commit Graph

103 Commits

Author SHA1 Message Date
Frédéric Hardy 615558394a Remove bug in locale management in listener. 2012-07-03 16:15:48 +02:00
Fabien Potencier 81fe2ff8e2 merged branch fabpot/locale-listener (PR #4692)
Commits
-------

88caf3a [HttpKernel] removed the storage of the current locale in the session

Discussion
----------

[HttpKernel] removed the storage of the current locale in the session

Before this commit, the current locale was stored in the session (if one
was already started). That way, for the next requests, even if the
request locale attribute was not set, the locale was "restored".

But this is a really bad practice as it means that the same URL can have
a different content depending on the previous requests. It would have
been better if the Vary header was set but the locale can be different
from the value coming from the Accept-Language anyway.

This is a BC break but fortunately, you can restore the 2.0 behavior by
creating a simple event listener that contains the logic removed by this
commit.

---------------------------------------------------------------------------

by travisbot at 2012-07-01T06:56:48Z

This pull request [fails](http://travis-ci.org/symfony/symfony/builds/1748659) (merged 009e30f0 into 2e356c1a).

---------------------------------------------------------------------------

by schmittjoh at 2012-07-01T08:15:46Z

How about using a cookie instead? It would remove the BC break, and also be possible to use a vary header?

---------------------------------------------------------------------------

by fabpot at 2012-07-01T09:13:44Z

The goal is to make Symfony as stateless as possible; introducing a cookie would defeat this goal.

---------------------------------------------------------------------------

by drak at 2012-07-01T09:19:37Z

@fabpot - thank you for bringing this to attention. I was meaning to do it a long time ago. The requested language is entirely a per request issue and must always be so. URLs must only ever return one content, and not multiple (e.g. different languages). The correct way to behave is to detect the language based on URL and failing that where a language is not requested, to look at the preferred language from the browser request and if available it can be redirected to that resource (e.g. /fr). This is what we do in Zikula. We have a further session based setting for "preferred language" which if set will override the browser default.

In summary:

1. If the language is specified in the GET request, return that language always. E.g. domain.com/fr/foo should return a French version of foo

2. If no language is specified in the GET request: first check the session for a preferred language, otherwise check the browser string for the preferred language and then if necessary, redirect to that resource. We have a setting which additionally say "always have language in URL, and don't put language code in URL for default language"

This means what in Zikula we only ever have one URL per language version of a page, but it still allows for users to set their preferred language which is taken in to account mainly when they visit the homepage (but in fact any page without a specific language in the request).

---------------------------------------------------------------------------

by drak at 2012-07-01T09:38:06Z

+1 on this PR. Basically the request locale should be in the Request object and calculated according to the applications preferences.

---------------------------------------------------------------------------

by schmittjoh at 2012-07-01T12:38:25Z

I agree that content must be detected based on the request, but I strongly disagree with relying entirely on the URL.

@fabpot, if you think about it using a cookie would still be stateless. There would be no state whatsoever, the detection would be entirely based on the request. Whether the language information is transmitted in the URL or as part of request headers is for the developer to decide eventually, at least IMO. My suggestion would just provide a default which is more BC.

---------------------------------------------------------------------------

by drak at 2012-07-01T20:08:50Z

@schmittjoh it's not entirely from the URL, there are browser preferences and also user defaults ca nalso available but the latter is slightly higher level. IMO it's not really Symfony's job here, it's application level specific. We have a pretty good working example of that in Zikula. Anyone can easily implement your own requirements with a listener.

What is absolutely clear however is it is wrong for one URL to deliver more than one version of any content.

---------------------------------------------------------------------------

by schmittjoh at 2012-07-01T21:16:52Z

I'm 100% for this change. My suggestion would just be more BC while still keeping Symfony2 stateless. Of course, it can be easily implemented in userland if we do not care about BC here.

Regarding different URLs per content, I do not think that this is our decision to make. Generally, developers should be able to make whatever content negotation they see fit. Whether they rely solely on the URL, or also take other request headers into account should not be limited by Symfony2.

---------------------------------------------------------------------------

by fabpot at 2012-07-02T10:37:26Z

I've added a paragraph in the UPGRADE file with a listener example that can be used to keep BC.
2012-07-02 12:37:57 +02:00
Fabien Potencier 88caf3a370 [HttpKernel] removed the storage of the current locale in the session
Before this commit, the current locale was stored in the session (if one
was already started). That way, for the next requests, even if the
request locale attribute was not set, the locale was "restored".

But this is a really bad practice as it means that the same URL can have
a different content depending on the previous requests. It would have
been better if the Vary header was set but the locale can be different
from the value coming from the Accept-Language anyway.

This is a BC break but fortunately, you can restore the 2.0 behavior by
creating a simple event listener that contains the logic removed by this
commit.
2012-07-02 12:36:25 +02:00
Fabien Potencier c0e4760b38 merged branch kriswallsmith/form/mv-humanize (PR #4645)
Commits
-------

c1e4166 moved create of default form label to view layer

Discussion
----------

move create of default form label to view layer

A small optimization if you provide custom labels in the view layer (i.e. `{{ form_label(form.name, 'Your name') }}`

```
Bug fix: no
Feature addition: no
Backwards compatibility break: yes
Symfony2 tests pass: yes
Fixes the following tickets: ~
Todo: ~
License of the code: MIT
Documentation PR: ~
```

---------------------------------------------------------------------------

by travisbot at 2012-06-24T14:45:17Z

This pull request [fails](http://travis-ci.org/symfony/symfony/builds/1694310) (merged 37f0b774 into 0d4b02e4).

---------------------------------------------------------------------------

by travisbot at 2012-06-24T15:03:44Z

This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1694418) (merged c1e4166e into 0d4b02e4).
2012-07-01 22:38:07 +02:00
Kris Wallsmith c1e4166ead moved create of default form label to view layer 2012-06-24 07:57:42 -07:00
Javier Lopez 731545de06 Fixed type, from repeated twice 2012-06-22 13:22:20 +02:00
Julien Brochet dacd8aa5e3 tweaked UPGRADE file 2012-06-16 19:50:09 +03:00
Michel Salib be637b5c23 Add upgrade for commit 0995b1f28b 2012-06-13 02:33:21 +03:00
Fabien Potencier fc40e53724 Revert "merged branch jfsimon/issue-4475 (PR #4497)"
This reverts commit f8a09db5e2, reversing
changes made to ae2ec36e27.
2012-06-09 21:38:22 +02:00
Fabien Potencier f8a09db5e2 merged branch jfsimon/issue-4475 (PR #4497)
Commits
-------

06976fc Updated upgrade 2.1 file.
110ccd8 [BrowserKit] Updated changelog.
686854b [http kernel] Added client response type test.
ce7e1e6 [browser kit] Client now stores filtered response after request.

Discussion
----------

[browser kit] Client now stores filtered response after request.

Bug fix: yes
Feature addition: no
Backwards compatibility break: yes/no, choice is your
Symfony2 tests pass: yes

`Symfony\Component\HttpKernel\Client::request()` method now returns a `Symfony\Component\BrowserKit\Response` instance.

Fixes issue #4475.

---------------------------------------------------------------------------

by stof at 2012-06-05T08:58:00Z

This *is* as BC break as it changes the class returned by the method, even if the BC break is a bugfix to respect the epxected behavior :)

---------------------------------------------------------------------------

by jfsimon at 2012-06-05T09:05:32Z

@stof you're right!

---------------------------------------------------------------------------

by travisbot at 2012-06-06T15:29:54Z

This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1533533) (merged 686854b2 into 1541fe26).

---------------------------------------------------------------------------

by stof at 2012-06-09T10:12:18Z

@jfsimon can you add a note in the changelog of the component and in the upgrade file ?

---------------------------------------------------------------------------

by jfsimon at 2012-06-09T10:51:00Z

@stof done!

---------------------------------------------------------------------------

by travisbot at 2012-06-09T11:12:43Z

This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1575524) (merged 06976fcd into 1541fe26).

---------------------------------------------------------------------------

by stof at 2012-06-09T12:50:16Z

@fabpot 👍
2012-06-09 17:15:29 +02:00
Grégoire Paris f541a54770 [Form] implement force append / prepend 2012-06-09 17:05:41 +02:00
Jean-François Simon 06976fcd82 Updated upgrade 2.1 file. 2012-06-09 12:40:37 +02:00
Bernhard Schussek d6e80012b2 Fixed mistake in UPGRADE file 2012-06-01 07:59:14 +02:00
Jérémie Augustin 09e5f4629d fix markdown for code 2012-05-25 15:14:30 +03:00
Bernhard Schussek 94f6f7776a Restructured Form section of UPGRADE 2012-05-25 12:34:17 +02:00
Bernhard Schussek ee803cd948 [Form] Renamed setVars() to addVars() in FormViewInterface 2012-05-25 12:34:16 +02:00
Bernhard Schussek 2e6cdd15c5 [Form] Inverted the logic of "single_control" and renamed it to "compound". The opposite is now "simple". 2012-05-25 12:34:16 +02:00
Bernhard Schussek 98a7c0cf5f [Form] Consolidated FormInterface, FormBuilderInterface and FormViewInterface 2012-05-25 12:34:16 +02:00
Bernhard Schussek 8e128fc644 [Form][OptionsResolver] Fixed typos 2012-05-25 12:34:16 +02:00
Bernhard Schussek 877d8f7195 [Form] Reversed the order of $type and $name in FormFactory::createNamed[Builder]() 2012-05-25 12:34:16 +02:00
Bernhard Schussek 33fecca210 [Form] Merged various form events and added class FormEvent 2012-05-25 12:34:16 +02:00
Bernhard Schussek bec80157f9 [Form] Renamed client and application format to view and model format 2012-05-25 12:34:16 +02:00
Bernhard Schussek 8cae3282d8 [Form] setDefaultOptions() is now coded against OptionsResolverInterface 2012-05-25 12:34:16 +02:00
Bernhard Schussek 2cd99e80b6 [Form] Added FormBuilderInterface and FormViewInterface and cleaned up FormTypeInterface and FormTypeExtensionInterface 2012-05-25 12:28:17 +02:00
Bernhard Schussek 0ef4066983 [Form] Options are now passed to buildView() and buildViewBottomUp() 2012-05-25 12:28:17 +02:00
Bernhard Schussek 027259eba4 [Form] Changed getDefaultOptions() to setDefaultOptions(OptionsResolver $resolver) in FormTypeInterface 2012-05-25 12:28:17 +02:00
Bernhard Schussek 14225067eb [Form] Clarified the usage of "constraints" in the UPGRADE file 2012-05-22 11:22:27 +02:00
Bernhard Schussek af41a1a550 [Form] Fixed typos 2012-05-22 09:30:22 +02:00
Bernhard Schussek ac6939441f [Form] Allowed native framework errors to be mapped as well 2012-05-22 09:30:21 +02:00
Bernhard Schussek d0d1fe6182 [Form] Added more information to UPGRADE and CHANGELOG 2012-05-22 09:30:21 +02:00
Bernhard Schussek 081c6437e4 [Form] Updated UPGRADE and CHANGELOG 2012-05-22 09:30:21 +02:00
Bernhard Schussek 8f7e2f602c [Validator] Fixed: @Valid does not recurse the traversal of collections anymore by default 2012-05-22 09:29:53 +02:00
Bernhard Schussek 5e87dd885c [Form] Added tests for the case when "property_path" is null or false. Instead of setting "property_path" to false, you should set "mapped" to false instead. 2012-05-22 09:29:53 +02:00
Jakub Zalas 942cfc7a06 [Form] Removed index_generation mention from the UPGRADE instructions as the option no longer exists. 2012-05-08 13:56:34 +01:00
Albert Jessurum 251b93c8d9 Corrected typo on upgrade document 2012-05-06 13:34:55 +03:00
Bernhard Schussek d3bb4d085c [Form] Renamed option 'primitive' to 'single_control' 2012-04-27 10:18:25 +02:00
Bernhard Schussek eb75ab1b74 [Form] Fixed results of the FieldType+FormType merge. 2012-04-27 09:47:16 +02:00
Bernhard Schussek d9e142bd62 [Form] Restored and deprecated method `guessMinLength` in FormTypeGuesser 2012-04-23 16:02:44 +02:00
Joseph Rouff 991076ad82 Fix #3971 2012-04-19 11:20:58 +02:00
Fabien Potencier 85bb439356 merged branch bschussek/issue3878 (PR #3923)
Commits
-------

6e4ed9e [Form] Fixed regression: bind(null) was not converted to an empty string anymore
fcb2227 [Form] Deprecated FieldType, which has been merged into FormType
bfa7ef2 [Form] Removed obsolete exceptions
2a49449 [Form] Simplified CSRF mechanism and removed "csrf" type

Discussion
----------

[Form] Merged FieldType into FormType

Bug fix: no
Feature addition: no
Backwards compatibility break: yes
Symfony2 tests pass: yes
Fixes the following tickets: #3878
Todo: update the documentation on theming

![Travis Build Status](https://secure.travis-ci.org/bschussek/symfony.png?branch=issue3878)

This PR is a preparatory PR for #3879. See also #3878.

---------------------------------------------------------------------------

by juliendidier at 2012-04-13T14:25:19Z

What's the benefit ?

---------------------------------------------------------------------------

by henrikbjorn at 2012-04-13T14:26:40Z

why `input_widget` ? and not just `widget`

---------------------------------------------------------------------------

by Burgov at 2012-04-13T14:27:49Z

@juliendidier dynamic inheritance is now obsolete which fixes some other issues

---------------------------------------------------------------------------

by stloyd at 2012-04-13T14:37:26Z

What about __not__ breaking API so *badly* and leaving `FieldType` which will be simple like (with marking as deprecated):

```php
<?php

class FieldType extends AbstractType
{
    public function getParent(array $options)
    {
        return 'form';
    }

    public function getName()
    {
        return 'field';
    }
}

---------------------------------------------------------------------------

by bschussek at 2012-04-13T14:43:41Z

@stloyd That's a very good idea.

---------------------------------------------------------------------------

by mvrhov at 2012-04-13T17:41:21Z

IMHO what @stloyd proposed sounds like a good idea, but removing FieldType class, if #3903 will come into life might ensure that more forms will broke and people will check them thoroughly.

---------------------------------------------------------------------------

by r1pp3rj4ck at 2012-04-13T18:46:08Z

@bschussek looks great, but I'm concerned about how quickly will the third-party bundles adapt to this BC break. I hope really quick, because if they don't the whole stuff will be useless :S of course it's not your problem to solve.

---------------------------------------------------------------------------

by stof at 2012-04-13T18:50:32Z

@r1pp3rj4ck there is already another BC break requiring to update custom types for Symfony master. So third party bundles already have to do some work.

---------------------------------------------------------------------------

by r1pp3rj4ck at 2012-04-13T18:59:37Z

@stof which one? I've looked into @bschussek 's RFC about these [foo].bar stuff, but it's not yet implemented. Are you refering to this or another one I've missed?

---------------------------------------------------------------------------

by stof at 2012-04-13T19:04:06Z

@r1pp3rj4ck the change regarding default options

---------------------------------------------------------------------------

by r1pp3rj4ck at 2012-04-13T19:06:10Z

@stof oh, I forgot that one. Weird thing is that I've already changed my default options today and still forgetting these stuff :D

---------------------------------------------------------------------------

by bschussek at 2012-04-14T08:58:29Z

I restored and deprecated FieldType now. I'd appreciate further reviews.

---------------------------------------------------------------------------

by stloyd at 2012-04-14T09:02:32Z

Maybe we should try to avoid this BC in templates ? What do you think about similar move like with `FieldType` ? (hold old, but inside just render new)

---------------------------------------------------------------------------

by bschussek at 2012-04-14T09:07:22Z

@stloyd You mean for those cases where people explicitely render the block "field_*"? We can do that.

---------------------------------------------------------------------------

by stloyd at 2012-04-14T09:09:45Z

@bschussek Yes I mean this case =) Sorry for not being explicit, I need some coffee I think =)

---------------------------------------------------------------------------

by bschussek at 2012-04-17T14:45:35Z

I added the field_* blocks again for BC. Could someone please review again? Otherwise this can be merged.

---------------------------------------------------------------------------

by Burgov at 2012-04-17T15:11:16Z

@bschussek I'm not sure what has changed to cause this, but if I try out your branch on our forms, if I leave the value of an input empty, eventually the reverseTransform method receives a null value, rather than a '' (empty string) value, as on the current symfony master.

DateTimeToLocalizedStringTransformer, for example, will throw an Exception if the value is not a string

```php
if (!is_string($value)) {
   throw new UnexpectedTypeException($value, 'string');
}
```

Other than that, all forms render just the same as they do on symfony master

---------------------------------------------------------------------------

by bschussek at 2012-04-17T15:30:29Z

@Burgov Fixed.
2012-04-18 12:50:00 +02:00
Fabien Potencier a47a5aa52c merged branch umpirsky/issue-3379 (PR #3922)
Commits
-------

24bd8f4 Added missing dot to translation messages.
4bff221 Added missing dot to translation messages.
7454894 Added missing dot to translation messages.
6e90c50 Updated upgrade instructions.
7e21dd1 Added missing dot to translation messages.

Discussion
----------

Issue 3379

This should fix [issues 3379](https://github.com/symfony/symfony/issues/3379)

---------------------------------------------------------------------------

by stof at 2012-04-13T15:06:32Z

Your branch conflicts with master. Please rebase it

---------------------------------------------------------------------------

by umpirsky at 2012-04-13T19:11:54Z

@stof I tried to rebase, I'm not sure if I did everything right. Is it ok now?

---------------------------------------------------------------------------

by umpirsky at 2012-04-13T19:12:06Z

@stof I tried to rebase, I'm not sure if I did everything right. Is it ok now?

---------------------------------------------------------------------------

by mvrhov at 2012-04-13T19:19:34Z

IMHO no, because there are commits from other people. Did you follow the [instructions](http://symfony.com/doc/current/contributing/code/patches.html#id1)?

---------------------------------------------------------------------------

by stof at 2012-04-13T19:36:53Z

@mvrhov commits from others ?

---------------------------------------------------------------------------

by umpirsky at 2012-04-13T19:41:53Z

@stof There were some, so I reverted. Now I'm trying again following instructions from Symfony doc.

I come to this:

```
$ git push origin issue-3379
To git@github.com:umpirsky/symfony.git
 ! [rejected]        issue-3379 -> issue-3379 (non-fast-forward)
error: failed to push some refs to 'git@github.com:umpirsky/symfony.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.
```

And I don't know how to fix this. Any idea?

---------------------------------------------------------------------------

by stof at 2012-04-13T19:43:45Z

@umpirsky when you rebase, it is logical to need to force the push

---------------------------------------------------------------------------

by umpirsky at 2012-04-13T19:44:38Z

@stof I did `git push -f origin issue-3379`. I hope it's fixed now.

---------------------------------------------------------------------------

by maoueh at 2012-04-13T20:39:34Z

@umpirsky seems better than last time I checked :)

---------------------------------------------------------------------------

by umpirsky at 2012-04-13T20:43:04Z

@maoueh Is it good enough? :)

---------------------------------------------------------------------------

by maoueh at 2012-04-13T20:51:27Z

@umpirsky At least, the rebase seems good enough :D As for the subject of the PR, I don't pronounce myself ;)

---------------------------------------------------------------------------

by vicb at 2012-04-13T20:53:23Z

you should probably squash the commits
2012-04-18 11:57:20 +02:00
Bernhard Schussek 5208bbec8a [Validator] Fixed typo, updated CHANGELOG and UPGRADE 2012-04-17 17:19:12 +02:00
Bernhard Schussek fcb2227ac9 [Form] Deprecated FieldType, which has been merged into FormType 2012-04-17 16:44:39 +02:00
Sasa Stamenkovic 6e90c508d6 Updated upgrade instructions. 2012-04-13 21:43:24 +02:00
Bernhard Schussek 6df7a7223e [Form] Deprecated FormValidatorInterface and moved implementations to event listeners 2012-04-13 16:42:01 +02:00
Richard Miller 7276a04fe8 Added some more bc breaks to UPGRADE-2.1.md from the changelog 2012-04-11 17:24:00 +01:00
Fabien Potencier 05842c54b8 merged branch bschussek/issue3354 (PR #3789)
Commits
-------

8329087 [Form] Moved calculation of ChoiceType options to closures
5adec19 [Form] Fixed typos
cb87ccb [Form] Failing test for empty_data option BC break
b733045 [Form] Fixed option support in Form component

Discussion
----------

[Form] Fixed option support in Form component

Bug fix: yes
Feature addition: no
Backwards compatibility break: yes
Symfony2 tests pass: yes
Fixes the following tickets: #3354, #3512, #3685, #3694
Todo: -

![Travis Build Status](https://secure.travis-ci.org/bschussek/symfony.png?branch=issue3354)

This PR also introduces a new helper `DefaultOptions` for solving option graphs. It accepts default options to be defined on various layers of your class hierarchy. These options can then be merged with the options passed by the user. This is called *resolving*.

The important feature of this utility is that it lets you define *lazy options*. Lazy options are specified using closures that are evaluated when resolving and thus have access to the resolved values of other (potentially lazy) options. The class detects cyclic option dependencies and fails with an exception in this case.

For more information, check the inline documentation of the `DefaultOptions` class and the UPGRADE file.

@fabpot: Might this be worth a separate component? (in total the utility consists of five classes with two associated tests)

---------------------------------------------------------------------------

by beberlei at 2012-04-05T08:54:10Z

"The important feature of this utility is that it lets you define lazy options. Lazy options are specified using closures"

What about options that are closures? are those differentiated?

---------------------------------------------------------------------------

by bschussek at 2012-04-05T08:57:35Z

@beberlei Yes. Closures for lazy options receive a Symfony\Component\Form\Options instance as first argument. All other closures are interpreted as normal values.

---------------------------------------------------------------------------

by stof at 2012-04-05T11:09:49Z

I'm wondering if these classes should go in the Config component. My issue with it is that it would add a required dependency to the Config component and that the Config component mixes many different things in it already (the loader part, the resource part, the definition part...)

---------------------------------------------------------------------------

by sstok at 2012-04-06T13:36:36Z

Sharing the Options class would be great, and its more then one class so why not give it its own Component folder?
Filesystem is just one class, and that has its own folder.

Great job on the class bschussek 👏

---------------------------------------------------------------------------

by bschussek at 2012-04-10T12:32:34Z

@fabpot Any input?

---------------------------------------------------------------------------

by bschussek at 2012-04-10T13:54:13Z

@fabpot Apart from the decision about the final location of DefaultOptions et al., could you merge this soon? This would make my work a bit easier since this one is a blocker.

---------------------------------------------------------------------------

by fabpot at 2012-04-10T18:08:18Z

@bschussek: Can you rebase on master? I will merge afterwards. Thanks.
2012-04-11 17:03:28 +02:00
Bernhard Schussek 5adec19f56 [Form] Fixed typos 2012-04-11 16:37:42 +02:00
Bernhard Schussek b7330456b6 [Form] Fixed option support in Form component 2012-04-11 16:37:42 +02:00
Richard Miller f23b4fa3f2 Added some bc breaks from the changelog into UPGRADE-2.1.md 2012-04-11 15:01:47 +01:00