Commits
-------
ef022c0 Removed the magical guessing of the type name to avoid WTF issues
Discussion
----------
Removed the magical guessing of the type name to avoid WTF issues
As discussed on IRC, this removes the magical method to avoid breaking the user-land code by reusing the same name than another type which overrides it. This makes the user aware that a type should have a name as they now have to implement the method themselves.
---------------------------------------------------------------------------
by jalliot at 2011/07/06 05:35:30 -0700
Doc and generator should be modified as well if it's merged.
Commits
-------
133169f Better exception message for extension in XmlFileLoader
Discussion
----------
Better exception message for XmlFileLoader
Include namespace that has been looked for an registered namespaces in the exception message to ease debugging.
Commits
-------
fa20b51 [Console] refactored definition printer
e49d61f [Console] fixed console help printing expectations
Discussion
----------
[Console] definitions printing fix
Before this change, console component printed definitions as:
``` bash
Arguments:
features Feature(s) to run. Could be a dir (features/),
a feature (*.feature) or a scenario at specific line
(*.feature:10).
Options:
--config (-c) Specify external configuration file to load. behat.yml or config/behat.yml will be used by default.
--profile (-p) Specify configuration profile to use. Define profiles in config file (--config).
--init Create features directory structure.
--format (-f) How to format features. pretty is default. Available formats are
- pretty
- progress
- html
- junit
--out Write formatter output to a file/directory instead of STDOUT (output_path).
--colors Force Behat to use ANSI color in the output.
--no-colors Do not use ANSI color in the output.
--no-time Hide time in output.
--lang Print formatter output in particular language.
--no-paths Do not print the definition path with the steps.
--no-snippets Do not print snippets for undefined steps.
--no-multiline No multiline arguments in output.
--expand Expand Scenario Outline Tables in output.
--story-syntax Print *.feature example in specified language (--lang).
--definitions Print available step definitions in specified language (--lang).
--name Only execute the feature elements (features or scenarios) which match part of the given name or regex.
```
As you might see, indentation is totally broken (also notice how it prints multiline descriptions in argument and --format option).
This PR makes output looks like this:
``` bash
Arguments:
features Feature(s) to run. Could be a dir (features/),
a feature (*.feature) or a scenario at specific line
(*.feature:10).
Options:
--config (-c) Specify external configuration file to load. behat.yml or config/behat.yml will be used by default.
--profile (-p) Specify configuration profile to use. Define profiles in config file (--config).
--init Create features directory structure.
--format (-f) How to format features. pretty is default. Available formats are
- pretty
- progress
- html
- junit
--out Write formatter output to a file/directory instead of STDOUT (output_path).
--colors Force Behat to use ANSI color in the output.
--no-colors Do not use ANSI color in the output.
--no-time Hide time in output.
--lang Print formatter output in particular language.
--no-paths Do not print the definition path with the steps.
--no-snippets Do not print snippets for undefined steps.
--no-multiline No multiline arguments in output.
--expand Expand Scenario Outline Tables in output.
--story-syntax Print *.feature example in specified language (--lang).
--definitions Print available step definitions in specified language (--lang).
--name Only execute the feature elements (features or scenarios) which match part of the given name or regex.
```
Commits
-------
d08a688 [Form] Fixed CS
954bdb5 [Form] Updated DateTimeType to accept a custom date pattern for the DateType child * Added a test also about this change
e7e744f [Form] Synced changes in this branch with current Symfony master branch
436cb95 [Form] Changed to a CreateException when the 'format' option is invalid * Updated DateTypeTest also
0045ffe [Form] Added tests to check that the date format option is validated correctly * Format option must be either a IntlDateFormatter constants (FULL, LONG, MEDIUM, SHORT) or a string
a815232 [Form] The IntlDateFormatter pattern can now be passed via the format option * Also changed the default value of the calendar paramter to \IntlDateFormatter:GREGORIAN in DateTimeToLocalizedStringTransformer which is the same as the default value in StubIntlDateFormatter
58f869a [Form] Synced custom pattern tests with master branch
c20edde [Form] Added some tests * Tests to check if the pattern option is handled correctly by DateType * Tests to check if the pattern parameter is handled correctly by DateTimeToLocalizedStringTransformer
52a1e1d moved date_pattern to IntlDateFormatter
dd104bc added code to use custom date_pattern
Discussion
----------
[Form] Added code to use custom date_pattern
Current DateType doesn't make use of the `date_pattern` option. Added code to use the custom `date_pattern` if provided.
---------------------------------------------------------------------------
by maoueh at 2011/05/02 21:52:37 -0700
You should also pass the pattern option to the DateTimeToLocalizedStringTransformer so the pattern is taken in consideration when converting from and to localized string. You can check the commit I did on my repository (maoueh/symfony@01ae75dd84) which do the same as yours for the DateType but also includes the modification needed by the DateTimeToLocalizedStringTransformer class.
Not sure if there is more work needed to fully support the pattern option. Moreover, I did not run the tests to check if everything pass correctly. It would also be a good idea to add some tests to check that the date_pattern is working as expected.
---------------------------------------------------------------------------
by dot-i-fy at 2011/05/02 22:02:14 -0700
There is also a problem with the regex, but this is not regarding the pattern option. If you set the 'format' option to 0, it returns the IntlDateFormatter::FULL but it does not pass the regex because there is first EEEE in the standard pattern so it comes on the fallback pattern year month day
---------------------------------------------------------------------------
by kertz at 2011/05/02 23:36:05 -0700
Thanks for your suggestions @maoueh and @dot-i-fy, I will check them.
I found the `date_pattern` doesn't work when using text widget. I will try to fix this.
---------------------------------------------------------------------------
by dot-i-fy at 2011/05/03 00:02:45 -0700
Here the regex I use now and working with IntlDateFormatter::FULL
https://gist.github.com/952929
---------------------------------------------------------------------------
by maoueh at 2011/05/03 07:13:01 -0700
@kertz: It is working for me using the text widget on my development machine. Don't know what is the problem on our side but it is working correctly for me. I'm willing to help track this problem if you want. Just let me know.
---------------------------------------------------------------------------
by dot-i-fy at 2011/05/03 07:57:34 -0700
@kertz : It is also working for me, we just have to pay attention about the format to be used in the text input regarding IntlDateFormatter.
---------------------------------------------------------------------------
by kertz at 2011/05/03 11:15:23 -0700
Ah well I guess I screwed up the whole commit log!
---------------------------------------------------------------------------
by dot-i-fy at 2011/05/03 11:19:08 -0700
wow !
---------------------------------------------------------------------------
by maoueh at 2011/05/03 11:23:51 -0700
Hell yeah! :) You should do a rebase the next time instead of merging Symfony master branch into yours:
`git rebase symfony/master date_pattern` and when you need to push your changes to your repository, do `git push -f origin date_pattern`. This way, it will be easier for the core team to handle the merge process.
Since @dot-i-fy opened a pull request for fixing the same issue as here, maybe it would be a good idea to close this PR?
---------------------------------------------------------------------------
by kertz at 2011/05/03 11:33:34 -0700
Well, it's done. I just pushed it a little earlier that I should have! Well I didn't know that @dot-i-fy opened a PR, where is it? This patch currently works for me.
Regarding the change in regex, well I think it should also have a ChoiceList for week days, otherwise it's not useful. Probably that alone can be a separate PR.
---------------------------------------------------------------------------
by maoueh at 2011/05/03 11:46:09 -0700
Yep it is much better now :) I think it would be a good idea to remove this commit from your PR kertz/symfony@e47cfb6d49.
The other PR is [PR751](https://github.com/symfony/symfony/pull/751). Maybe @dot-i-fy could change is PR so it will only be about the regex? In both cases, you should coordinate with each other I think.
Thanks for merging the changes I made to the DateTimeToLocalizedStringTransformer class.
---------------------------------------------------------------------------
by dot-i-fy at 2011/05/03 12:00:06 -0700
Yeah, I will modify my commit to take only the regex in account.
Would someone work with me on the TimeType ? The pattern is also not working there but it looks like a little bit more complicated!
Thanks
---------------------------------------------------------------------------
by kertz at 2011/05/03 12:02:18 -0700
Thanks for the changes in DateTimeToLocalizedStringTransformer.
Is it really necessary to remove the initial commit?
---------------------------------------------------------------------------
by dot-i-fy at 2011/05/03 12:06:41 -0700
What does it mean CS ?
---------------------------------------------------------------------------
by maoueh at 2011/05/03 12:08:44 -0700
@dot-i-fy: It means Code Style, the comma is not placed correctly
---------------------------------------------------------------------------
by kertz at 2011/05/03 12:11:24 -0700
`Coding Standards` seems right :) http://symfony.com/doc/2.0/contributing/code/standards.html
---------------------------------------------------------------------------
by dot-i-fy at 2011/05/03 12:11:27 -0700
ah ok, thx
---------------------------------------------------------------------------
by maoueh at 2011/05/03 12:12:10 -0700
@kertz: I don't think it is strictly necessary to remove this commit. But I think it is a good idea since you kinda reverted it with some changes in a later commit. The core team might ask you to remove it. So leave it for now, and change it if they ask you to do so.
Hehe right, Coding Standards looks way better :)
---------------------------------------------------------------------------
by maoueh at 2011/05/03 12:30:00 -0700
@dot-i-fy: I will check later in the evening what can be done about the pattern in the TimeType class. I'm also planning on adding some tests about this PR. If I do so, I will send a PR to your repository @kertz so you will be able to add the tests to this PR.
---------------------------------------------------------------------------
by dot-i-fy at 2011/05/03 13:04:35 -0700
I had some problems with PHPUnit, seems to be ok now. Another problem, damned, APC is showing in my browser when in app_dev.php, not in prod. Any idea ? Can't get html output in dev env.
---------------------------------------------------------------------------
by dot-i-fy at 2011/05/04 00:43:46 -0700
@RapotOR : Are you talking about the dateType method in IntlDateFormatter ? If no can you make a snippet in gist with an example ?
If yes ...The option "format" already allows an IntlDateFormatter input, you can either set a \IntlDateFormatter::MEDIUM for example or an integer representing the dateType to use (0 -> full, 1 -> long, ... ).
The problem we are reveling here is the pattern based off the dateFormat option :
the $formatter look for Locale -> then for format option and based off these options he generate a pattern who can be different regarding the Locale. For example, for me I have my locale in php set to fr_BE, so my dates are always d-m-Y formatted but if I want to modify that it is momently not possible.
Grtz
---------------------------------------------------------------------------
by RapotOR at 2011/05/04 00:57:03 -0700
@dot-i-fy : my thought was more about having a full control of IntlDateFormatter from outside; instead of defining every variables. It is more like a DI way... especially if you have more than one DateType field!
---------------------------------------------------------------------------
by dot-i-fy at 2011/05/04 01:11:21 -0700
Oh so, it may be indeed a nice way to follow. Don't hesitate to submit your code suggestions.
But I think that if we go deeper in the core modifications, it is maybe a solution to take the $formatter out of the dateType class and put it in a own class and call it from the dateType class ???@}#
---------------------------------------------------------------------------
by maoueh at 2011/05/05 08:22:40 -0700
@mweimerskirch: Maybe it would be better to rename your option html_pattern? Since the pattern is not strictly associated to a date type, it would be a better name in my opinion if it was named html_pattern or html5_pattern?
I think it would lead to more misunderstandings if we had a date_pattern and a pattern option. In both cases, I agree totally that one or the other needs a renaming. Moreover, if we change the pattern option in the date type, I think the format option should be changed also to date_format.
What do you think?
---------------------------------------------------------------------------
by kertz at 2011/05/05 23:58:21 -0700
@mweimerskirch
I too think when we specify `pattern` in `DateType` everyone expects it to be the date pattern. So maybe renaming the HTML5 pattern to `html_pattern` would be more appropriate?
---------------------------------------------------------------------------
by bschussek at 2011/05/18 12:20:56 -0700
Looks good. Why don't we reuse the "format" option for this? If "format" is not one of the predefined constants, we could treat it as a custom date format.
---------------------------------------------------------------------------
by maoueh at 2011/05/18 12:28:22 -0700
@bschussek: I think it is a good idea indeed. When I first played with forms, I thought that the purpose of the format option was exactly for this but I soon realized it wasn't. I'm +1 for this.
@kertz: Let me know if you don't have time to do this switch, I will gladly submit the changes to you own repo if we agree to use "format" option instead of the "pattern" one.
---------------------------------------------------------------------------
by dot-i-fy at 2011/05/18 12:33:33 -0700
``format`` and ``pattern`` options are related to the IntlDateFormatter, I also agree with you but we have to keep in mind that we will loose the symmetry with the IntlDateFormatter class.
---------------------------------------------------------------------------
by bschussek at 2011/05/18 13:39:07 -0700
I think we can safely add this level of abstraction.
---------------------------------------------------------------------------
by kertz at 2011/05/18 20:29:11 -0700
@maoueh Would be great if you can make the changes :)
---------------------------------------------------------------------------
by dot-i-fy at 2011/05/19 09:09:41 -0700
@bschussek : I saw you removed pattern option, what are further intentions ?
---------------------------------------------------------------------------
by maoueh at 2011/05/19 09:42:40 -0700
@kertz: I will do the changes needed tomorrow as I have some spare times. You will need to sync your branch with current master or I will need to send another PR since @bschussek removed the pattern option which will cause bad conflicts with this implementation.
---------------------------------------------------------------------------
by kertz at 2011/05/20 06:45:22 -0700
@maoueh I've merged the changes.
---------------------------------------------------------------------------
by kertz at 2011/05/20 07:11:36 -0700
@maoueh I just removed a couple of commits from the log. Seems like the tests you committed are now missing from the PR. Can you please send the tests once again? Sorry about that.
---------------------------------------------------------------------------
by maoueh at 2011/05/20 09:03:52 -0700
@kertz: I will resend them along with the code modifications to use `format` instead of `pattern`.
---------------------------------------------------------------------------
by maoueh at 2011/05/20 19:11:28 -0700
I did the changes to make it possible to pass a custom pattern via the format option. I sent a PR on @kertz repository [here](https://github.com/kertz/symfony/pull/2) that will be merge eventually in this PR.
I have two small questions about it. First, since format option can now be a string, the allowed values for the option `format` have been removed from the array returned by `getAllowedOptionValues`. The check is done instead in the method `buildForm` directly. The 'format' option can be either one of the `IntlDateFormatter` constants (FULL, LONG, MEDIUM, or SHORT) or a string. If those conditions are not respected, a `FormException` is thrown. Is this correct?
When the `format` option is a custom pattern, the IntlDateFormatter needs a valid format even if it will not be used. So I retrieved the default format option by using the `getDefaultOptions` method. Is this correct or should I specify the default value directly:
this (specify directly):
$format = \IntlDateFormatter::MEDIUM;
instead of (use predefined defaults):
$defaultOptions = $this->getDefaultOptions($options);
$format = $defaultOptions['format'];
Also added more tests to verify that the format option is validated correctly and updated previous ones.
Regards,
Matt
---------------------------------------------------------------------------
by kertz at 2011/05/20 20:38:32 -0700
Merged the changes. I have not tested this yet... Thanks @maoueh :)
---------------------------------------------------------------------------
by dot-i-fy at 2011/05/20 22:48:47 -0700
nice job @maoueh
---------------------------------------------------------------------------
by mprizmic at 2011/06/16 14:06:47 -0700
what do you think about
$pattern = $form->getAttribute('pattern');
instead of
$pattern = $form->getAttribute('formatter')->getPattern();
in line 96 of
symfony/component/form/extension/core/type/datetype.php
---------------------------------------------------------------------------
by maoueh at 2011/06/16 14:40:37 -0700
It is simpler to use the pattern of the formatter directly I think. The reason is that if the option to change the format is null, the default pattern of the formatter will be available and will be the right pattern to use. If the option is set, we modify the formatter before hand so getting the pattern from it will return the custom pattern we have set in the options.
So in both cases, no conditional is required to verify if it is set or not when retrieving the pattern from the formatter. Moreover, I think the pattern must be set as an attribute of the form for your suggestion to work correctly which is not the case right now.
Regards,
Matt
---------------------------------------------------------------------------
by stloyd at 2011/07/05 13:41:36 -0700
@fabpot What we do with that ? I have tried to rebase it with master, but my (Windows) git always gets insane and this ends up with unfixable error. This feature __should__ be in Symfony2 before final. Should I start work on it from "none" ?
---------------------------------------------------------------------------
by fabpot at 2011/07/06 05:44:26 -0700
@stloyd: I need to review the patch first.
The guesser has been removed as the constraints only knows
about the valid keys. But to be able to create the Type automatically,
we also need the values.
Commits
-------
3df5ec3 [HttpKernel] Add support for 'upload_max_filesize' ini directive in the Client
Discussion
----------
[HttpKernel] Add support for 'upload_max_filesize' ini directive
[HttpKernel] Add support for 'upload_max_filesize' ini directive in the Client
__This PR depends on #1542__
This PR prevent the SW Client from uploading files larger than the limit set in php.ini to closer mimic a real browser usage.
If both PR eventually gets merge `static protected function getMaxUploadFilesize()` should probably be factorized to the UploadedFile class.
---------------------------------------------------------------------------
by stloyd at 2011/07/05 13:35:06 -0700
+1 for both, I just have found similar "wtf" issues with "empty" `upload_max_filesize`.
---------------------------------------------------------------------------
by oscarballadares at 2011/07/05 15:13:23 -0700
I have opened an issue related to UPLOAD_ERR_INI_SIZE. There was no way to handle this exception.
Can you confirm please?
If this is the case I will close the issue I opened.
---------------------------------------------------------------------------
by vicb at 2011/07/05 23:04:08 -0700
@oscarballadares the PR you are looking for is most probably #1542 - which you should see in the message thread of your submitted issue.
The best would be for you to verify that PR #1542 fixes your issue and provide some feedback so that the issue can be close but only when the PR gets merged (if it fixes the issue).
Commits
-------
d58ba34 [Validator] Consider the ini directive 'upload_max_filesize' while validating an uploaded file (fixes GH-1441)
Discussion
----------
[Validator] FileValidator support for uploaded files
[Validator] Consider the ini directive 'upload_max_filesize' while validating an uploaded file (fixes GH-1441)
Added validator messages should get translated in all the available languages.
Commits
-------
4c6e177 [Form] Fix the default validator
Discussion
----------
[Form] Fix the default validator
When php.ini has an empty value for post_max_size
`post_max_size =`
see http://fr2.php.net/manual/en/function.ini-get.php
post_max_size can not be false as it has a default value
Commits
-------
03fee4f Fix permissions
431460f [Form] Remove choice or choice_list requirement as the following conditions already check enough and this condition prevents empty select forms (populated by ajax for example)
Discussion
----------
[Form] Choice fix
[Form] Remove choice or choice_list requirement as the following conditions already check enough and this condition prevents empty select forms (populated by ajax for example)
---------------------------------------------------------------------------
by stloyd at 2011/07/05 06:26:36 -0700
You should revert permission changes.
---------------------------------------------------------------------------
by fabpot at 2011/07/05 06:28:14 -0700
Why not replacing `if (!$options['choices'] && !$options['choice_list']) {` by `if (!isset($options['choices']) && !isset($options['choice_list'])) { `?
---------------------------------------------------------------------------
by beberlei at 2011/07/05 06:35:50 -0700
gnaa permission changes, i cant seem to configure my machine such that it does not do it, i have to do this on a per repository basis, very annoying.
@fabpot isset() is already guaranteed because these two options are in the defaults.
---------------------------------------------------------------------------
by beberlei at 2011/07/05 06:39:43 -0700
Fixed the permissions
---------------------------------------------------------------------------
by stof at 2011/07/05 06:48:37 -0700
@beberlei Can't you fix it in the global git config ?
---------------------------------------------------------------------------
by webda2l at 2011/07/05 09:48:58 -0700
I met the same problem this afternoon and vote for the isset solution. Better than nothing and work for me.
https://github.com/symfony/symfony/pull/1539
---------------------------------------------------------------------------
by stof at 2011/07/05 09:50:09 -0700
@webda2l why is a check that always return true better than nothing ? It adds overhead without adding any value in the code.
Commits
-------
511a9a1 Edited src/Symfony/Component/Console/Helper/DialogHelper.php via GitHub
Discussion
----------
EOF triggers infinite loop in console dialog helper
* fix by throwing an exception when fgets() fails
* Also fixes "0" returning a default answer instead of "0"
---------------------------------------------------------------------------
by lenar at 2011/07/05 00:26:02 -0700
Fixes#1521.
Commits
-------
924ea92 made command consistent with other help texts (it's now './app/console', instead of 'php app/console')
8361346 Corrected help text from './symfony' to 'php app/console'
Discussion
----------
[console] Incorrect help text
When executing 'php app/console help', example commands starting with './symfony ' are shown.
I've made it consistent with the help text shown for generate:bundle; './app/console '
Commits
-------
3917ed7 Revert "* DateType, DateTimeType, TimeType: - a bit changed readability"
c85b815 Fixed few issues with Date and Time:
Discussion
----------
[Form] Fixed few issues with Date and Time
Fixed few issues with Date and Time:
* TimeType:
- seconds are no longer populated if "with_seconds" = false
- "widget = text" is now properly rendered (closes#1480)
* DateTimeToStringTransformer:
- fixed using not default "format" (probably fix#1183)
* DateType, DateTimeType, TimeType:
- fixed "input = datetime" and test covered
Commits
-------
756ea8d Call session_name() only if user gave an new one. Closes#1418
Discussion
----------
[Session] Call session_name() only if user gave an new one
Call `session_name()` only if user gave an new one, by default will use an "php.ini" option. Also added some phpdoc.
Closes#1418.
Commits
-------
2af2260 Remove useless code
Discussion
----------
Remove useless code
This PR is about removing useless code which could benefit to perfomances.
Credits go to [Jordi](https://github.com/symfony/symfony/commit/000229dbd0d161f1eebe) for this.
As a minor modif, I can understand if this could not be merged while in RC.
Commits
-------
164aea4 [Security] Add tests for the channel listener
d51cbc0 [Security] Remove useless attribute in basic authentication listener & test it
91e6dc9 [Security] Add tests for the anonymous authentication listener
3c2affb [Security] Update access listener constructor's prototype and add tests
81afd77 [Security] Add tests for the firewall map
aa6ae33 [Security] Remove useless attribute & var in firewall
Discussion
----------
Test security
---------------------------------------------------------------------------
by lsmith77 at 2011/06/29 13:41:07 -0700
@schmittjoh is probably the person to review this change ..
Commits
-------
49af102 Throwing FormNotBoundException when calling form isValid
Discussion
----------
Throwing FormNotBoundException when calling form isValid
---------------------------------------------------------------------------
by Seldaek at 2011/06/28 12:20:04 -0700
I'd have made that a `\LogicException`, but that's just me hating on custom exceptions. Otherwise as said on IRC, 👍.
---------------------------------------------------------------------------
by stloyd at 2011/06/28 12:27:27 -0700
+1 but IMO `FormException` would be here good enough.
Commits
-------
418d6a0 [Routing] Fix syntax error when dumping routes with single quotes in the requirements or pattern
2b5e22d [Routing] Fix ApacheDumper when a space appears in a default value
6c7f484 [Routing] Fix dumper so it doesn't print trailing whitespace
761724a [Routing] Adjust urlescaping rules, fixes#752
Discussion
----------
[Router] Bunch o' Fixes
The first commit changes the escaping rule to fix issues I had previously, and #752 as well, here's from the full commit message:
Only + and % are now encoded in generated routes, since they are the only characters that, if not encoded, could cause problems/conflicts when decoded. Namely + turns into a space, and % followed by numbers could do funky things.
The matcher decodes everything which works since nothing will have %NN without being escaped, and + are escaped as well.
Second commit is just a test fix for the first
Third and fourth are simply dumper escaping issues, nothing to argue about.
Note that all changes have had test cases added, and I spent a few hours torturing/testing all this stuff with both Apache and PHP dumpers, in many browsers, and with URLs as wonky as `/%01%02%03%04%05%06%07%08%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20!%22$%25&%27%28%29*+,-./0123456789:;%3C=%3E@ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B|%7D~/baz` which essentially represent the 1-255 char range minus ? and #.
The only issues I really encountered after all the patches were applied is that Apache refuses to match `%22` (= `"`) and `*` in a url. I guess it's just because they're not allowed chars in windows paths, but | and < > works fine though. Anyway this works with the PHP dumper, and it didn't work either without my patches so it's not like I broke it, I'm just saying for the record.
Commits
-------
1cc1027 added @Annotation to UniqueEntity
ee22c5d added a note to update file
efcb435 updated to doctrine changes
Discussion
----------
updated to doctrine changes
---------------------------------------------------------------------------
by excelwebzone at 2011/06/30 06:29:23 -0700
Should also be implemented to the Route class and to all SensioFrameworkExtraBundle annotation classes
* TimeType:
- seconds are no longer populated if "with_seconds" = false
- "widget = text" is now properly rendered (closes#1480)
* DateTimeToStringTransformer:
- fixed using not default "format" (probably fix#1183)
* DateType, DateTimeType, TimeType:
- fixed "input = datetime" and test covered
- a bit changed readability
Only + and % are now encoded in generated routes, since they are the only characters that, if not encoded, could cause problems/conflicts when decoded. Namely + turns into a space, and % followed by numbers could do funky things.
The matcher decodes everything which works since nothing will have %NN without being escaped, and + are escaped as well.
Commits
-------
f4c7333 Fix populating seconds when option "with_seconds" is set to false
Discussion
----------
[Form][DateTimeType] Fix invalid data when "with_seconds" = false
Fix populating seconds when option `with_seconds` is set to `false`.
Commits
-------
e80ce57 [HttpFoundation] Add REQUEST_TIME by default
Discussion
----------
[HttpFoundation] Add REQUEST_TIME by default
Without this the getting the REQUEST_TIME from the Request in tests is breaking.
Commits
-------
aeaf44a Removed unused code from DateTimeType
3c2539f Throw exception when "date_widget" option is not equal to "time_widget"
305c476 Overwrite child options ("widget", "empty_value") if any given
7bc19f9 Added to `DateTimeType` extension possibility to render form as `single_text` (similar to `DateType` option) (issue #1323 it requires fix for #1205)
17b41b2 Added to `TimeType` extension possibility to render form as `single_text` (similar to DateType option) (issue #1205) Adjusted `DateTimeType` to allow usage of this new feature
Discussion
----------
[Form][DateTimeType] Added "widget" and "empty_value" options
Hey,
I have just added "widget" and "empty_value" options to `DateTimeType`:
* `widget` option will overwrite existing `date_widget` and `time_widget`,
* `empty_value` behave exacly same way as it does for `ChoiceType`, `DateType` and `TimeType`
Also added and `FormException` when `date_widget` is not equal to `time_widget`, now is throwed non intuitive one (this will be changed in next days to allow different values for this options).
Closes#1323
Commits
-------
6b72cda removed whitespace
282a493 moved the constant from the interface back into the class
7ec7fbe fixed inteface name
9a82924 [Console] Extract the OutputFormatter's regular expression into the inteface.
Discussion
----------
[Console] Expose the OutputFormatter's regular expression
In my ConsoleBundle(https://github.com/CoreSphere/ConsoleBundle) I needed to decorate the OutputFormatter to enable html escaping while allow to apply styles.
For that I need to reuse the regular expression used in the original OutputFormatter. I think it would be cleaner exposing it than duplicating it.
(https://github.com/CoreSphere/ConsoleBundle/blob/master/Formatter/HtmlOutputFormatterDecorator.php#L64)
---------------------------------------------------------------------------
by fabpot at 2011/06/23 12:24:43 -0700
OutputFormatter is just one implementation of the interface, so the constant cannot be defined in the interface.
---------------------------------------------------------------------------
by laszlokorte at 2011/06/23 13:01:46 -0700
I made the false assumption all Formatters would use the same syntax for defining style. I moved it back into the class.
Commits
-------
4e3406d Sync with master and clean up
ad5d2c1 Added to `TimeType` extension possibility to render form as `single_text` (similar to DateType option) (issue #1205) Adjusted `DateTimeType` to allow usage of this new feature
Discussion
----------
[Form][TimeType] Added possibility to render form as "single_text"
Added to `TimeType` extension possibility to render form as `single_text` (similar to `DateType` option) (issue #1205)
Adjusted `DateTimeType` to allow usage of this new feature
---------------------------------------------------------------------------
by ouardisoft at 2011/06/17 03:41:18 -0700
+1
---------------------------------------------------------------------------
by stloyd at 2011/06/21 01:05:51 -0700
@fabpot Any decision about this one ? I'm asking because I also have similar fix for #1323 but it requires this one ;-)
---------------------------------------------------------------------------
by fabpot at 2011/06/22 23:32:08 -0700
@stloyd: Can you rebase to master?
---------------------------------------------------------------------------
by stloyd at 2011/06/23 05:03:44 -0700
@fabpot Done.
Commits
-------
a664a60 [Translation] support phar archives by XLIFF loader
Discussion
----------
[Translation] support phar archives by XLIFF loader
Support XLIFF translation files usage from phar package.
---------------------------------------------------------------------------
by fabpot at 2011/06/19 03:06:50 -0700
phar support is complex as not everything in PHP supports it. This patch only solves one area where phar is not supported. So, we need a solution that makes the entire framework phar-compatible, which is far from easy (realpath for instance cannot be used anywhere). So, I'm closing this PR and let's revisit the global phar support for 2.1.
---------------------------------------------------------------------------
by everzet at 2011/06/19 04:47:49 -0700
I'm not trying to package Symfony2 into phar :-) As it's indeed, very complex task even for 2.1. What i'm trying to do - i'm trying to package Behat in *.phar. And the only thing that blocks it - this PR. So, i'm not interested in full-stack phar support for entire Symfony2 framework right now, but as Symfony2 Components were created as stand-alone libs, this PR is enough to make Translation component itself supporting phar packaging. I use Translation component and XLIFF translations in Behat heavily and this PR gives me ability to create fully-working behat.phar package (tested).
Also, this PR doesn't breaks anything and even more - it's exactly the same piece of code, that we have in DependencyInjection component now: https://github.com/symfony/DependencyInjection/blob/master/Loader/XmlFileLoader.php#L327.
I'll be happy to work on phar support for 2.1. But for now, i can't see real reasons why Translation component can't already support it ;-)
Commits
-------
7db0b95 [HttpKernel] Removed unnecessary strtoupper
0891c57 [HttpKernel] Added test
1350645 [HttpKernel] Uppercased a few http methods
05c9906 [HttpKernel] Suppress response content for 304 responses out of the cache
Discussion
----------
HttpCache changes for 304 responses
Fixes#1413
To get the proper status for the Process, it needs to be terminated.
Sometimes, this is not the case when we call proc_get_status, so this
patch waits up to 1 sec to get the right information.
Commits
-------
d49e306 [DomCrawler] Fixed handling of relative query strings as links
a4451b4 [DomCrawler] Added tests for links starting with ?foo
Discussion
----------
[DomCrawler] Fixed handling of relative query strings as links
The link object concatenates links containing only a query string to the current URI. This shouldn't happen if the current URI already contains a query string.
This PR fixes the incorrect behavior (tests included).
Commits
-------
7783a05 Removed unused code from DateType Additional tests for ChoiceType and DateType based code
cdd39ac Added ability to set "empty_value" for `DateTimeType`, `DateType` and `TimeType` Additional tests covering added code
af4a7d7 More tests and more compatible code, with some suggestions from @helmer
527b738 Test covered version of fix for issue #1336
Discussion
----------
[Form] Added ability to set "empty_value" for choice list
Hey,
This PR is similar to #1336, but this one is fully test covered and have few change in behavior:
- if choice field is not set as non-required, `empty_value` is not added automaticly,
- also `empty_value` is not set if field have option `multiple` or `expanded`,
- `empty_value` for `DateType` and `TimeType` can be set "global" or per field, i.e.:
```
$builder->add('date', 'choice', array('required' => false, 'empty_value' => array('day' => 'Choose day')));
```
- `DateType` and `TimeType` code was cleaned a bit,
- added missing option to set up choice list as required when using PHP templates
---------------------------------------------------------------------------
by stloyd at 2011/06/20 04:55:45 -0700
@fabpot I'm just not sure is that change with removing "auto-adding" of `empty_value` is good (probably BC)
---------------------------------------------------------------------------
by lenar at 2011/06/20 05:24:02 -0700
Now this is a really nice way to hijack work done by others. Really encourages newcomers. Gratz!
---------------------------------------------------------------------------
by fabpot at 2011/06/20 05:57:40 -0700
@lenar: if the code in this PR is yours (at least partly), I'm not going to merge it. @stloyd, can you clarify this issue with @lenar? Thanks.
---------------------------------------------------------------------------
by lenar at 2011/06/20 06:21:11 -0700
It's @helmer's mostly, not mine, but the issue stays.
---------------------------------------------------------------------------
by fabpot at 2011/06/20 06:26:15 -0700
No matter who the code belongs to, Git allows us to keep track of all contributors. So, we need to do our best to not loose any code ownership.
---------------------------------------------------------------------------
by helmer at 2011/06/20 06:58:03 -0700
I do not care much for ownership, just that this kind of cooperation (or lack thereof) is kind of exhausting. Closed#1336.
---------------------------------------------------------------------------
by stloyd at 2011/06/20 07:47:53 -0700
@fabpot, @lenar: This PR is inspired by #1336, made by @helmer, but after looking at his code and talking with him, we cant (IMO) get an consensus. So I wrote this PR as an another way to fix issue described in #1336.
__Summary__: I don't think this one is better than fix at #1336, it's more like another approach to fix that issue.
---------------------------------------------------------------------------
by helmer at 2011/06/20 08:15:59 -0700
@stloyd: I actually think your variant is better, so good job there, thanks.
It just ain't nice to:
1) Comment on my changes being useless due to lack of tests
2) Writing brand new testsuite from your perspective that "proves" my approach is "wrong" (while ignoring my answers, why I did something precisely like I did, which I did in sync with @fabpot comments on his first attempt to improve the issue)
3) Saying my PR is broken because your new tests against it fail
4) Changing functionality to "fix" something that was not really broken
Other than that, I wanted to contribute a few lines to improve something relatively simple, and it ended up in a huge mess with more lost hours than I planned to spend on it.
On the bright side, we ended up with something good (:
---------------------------------------------------------------------------
by stloyd at 2011/06/20 08:32:30 -0700
@helmer: 1) & 2) Sorry for that "bad language", but you get me wrong a bit. Tests was written for code in master (there was no problem to change them to work with your POV). 3) Same as before, you can adopt tests easily, but never mind. Maybe later we could cooperate better ;-)
About 4) I mentioned it in description of this PR and that was point I was disagreeing with you (also about how "default" options are adopted in fields) :-)
Commits
-------
bda4129 Make run() fully non-blocking and fix potential other problems
Discussion
----------
Make run() fully non-blocking and fix potential other problems
Multiple changes:
1) make writing to process non-blocking too - otherwise there might be increased possibility for buffer deadlock
given big enough input data. Also now it's guaranteed that all stdin data will be written.
2) get rid of fgets() - fgets() isn't really good function to use in case of non-blocking sockets. Data loss possible.
Commits
-------
7af003b [HttpFoundation] Allow stringable objects and numbers in response body + added tests
8126fb7 [HttpFoundation] Ensure response body is string, fixes#1378
Discussion
----------
[HttpFoundation] Ensure response body is string, fixes#1378
The issue in #1378 is clearly just a misuse of the class due but the error it triggers is confusing. This hopes to fix that.
---------------------------------------------------------------------------
by Seldaek at 2011/06/21 04:08:40 -0700
Added tests and support for __toString + numbers (kinda pointless but well..)
This change removes the need for the {_locale} hack.
Now, all paths in the Security component can be:
* An absolute path (/login)
* An absolute URL (http://symfony.com/login)
* A route name (login)
So, if you want to use a path that includes a global parameter (like _locale),
use a route instead of a path.
Commits
-------
1cb5164 Replace some double quotes to single quotes
12259d1 Replace optionNal to optional
Discussion
----------
Fixed typo and double quotes within some strings
Fixed typo and double quotes within some strings
Commits
-------
159fc0e [Validator] Added symbols to IDNs validation
c827faf [Validator] Add support for IDNs and custom TLDs
Discussion
----------
[Validator] Add support for IDNs and custom TLDs
Minor changes to allow for IDNs and [custom TLDs](http://news.softpedia.com/news/ICANN-Approves-New-Custom-Generic-Top-Level-Domains-Like-google-bank-206977.shtml). This is the only sane way to support everything in a timeless manner.
---------------------------------------------------------------------------
by stealth35 at 2011/06/20 04:32:09 -0700
maybe it should be check the host with idn_to_ascii (if function exists, maybe it's should recreate un punycode en/decoder in the stub)
---------------------------------------------------------------------------
by mvrhov at 2011/06/20 04:40:10 -0700
/me :faceslap.
Haven't seen the link in PR
---------------------------------------------------------------------------
by Seldaek at 2011/06/20 04:40:40 -0700
@mvrhov: Yup, that's what pushed me to reconsider adding this.
@stealth35: I'm not sure if this is needed. I don't want this to be too strict, with another validator or with an extra option I think we can make a check that the domain actually exists, or do a GET / on it or something, but this just checks validity of the syntax.
---------------------------------------------------------------------------
by stealth35 at 2011/06/20 04:48:05 -0700
I understand :)
what about funny IDN like : [☎.com] (http://xn--y3h.com/) ?
---------------------------------------------------------------------------
by Seldaek at 2011/06/20 04:53:19 -0700
@stealth35: Fixed
---------------------------------------------------------------------------
by stealth35 at 2011/06/20 04:56:18 -0700
it's seem great,for acceptable chars [RFC] (http://www.faqs.org/rfcs/rfc3490.html) said (with UseSTD3ASCIIRules option) :
(a) Verify the absence of non-LDH ASCII code points; that is, the
absence of 0..2C, 2E..2F, 3A..40, 5B..60, and 7B..7F.
Commits
-------
f400124 [HttpFoundation] Small optimization of Session flash handling
Discussion
----------
[HttpFoundation] Small optimization of Session flash handling
Due to copy-on-write, this is faster and takes less memory unless the flashes are changed during the request, but that's not very likely as typically you set flashes, redirect, then show them, and at that point you do not modify them again.
Commits
-------
72d0ebe9 [WebProfilerBundle] Added the support of the the logging context in the template
410b3e0 [HttpKernel] Added the context in the LoggerInterface
Discussion
----------
context in the LoggerInterface
This adds the context in the LoggerInterface. The change is totally BC for people using the logger. However this affects people implementing the interface.
Note that this require Seldaek/monolog#33 for the implementation
---------------------------------------------------------------------------
by Seldaek at 2011/06/17 04:24:18 -0700
@fabpot: just ping me when you are merging this one, so I can merge in monolog and we avoid out-of-sync issues.
---------------------------------------------------------------------------
by stof at 2011/06/17 04:49:05 -0700
@Seldaek you can merge in Monolog when you want. Monolog is BC so merging it before the PR in Symfony2 does not break things.
---------------------------------------------------------------------------
by Seldaek at 2011/06/17 05:08:34 -0700
Ah right, I thought the interfaces wouldn't match, but PHP allows extra args it seems so I'll merge right now.
---------------------------------------------------------------------------
by stof at 2011/06/17 05:32:58 -0700
PHP allows extra *optionnal* args and it is the case here :)
---------------------------------------------------------------------------
by Seldaek at 2011/06/17 05:35:00 -0700
Well yes otherwise you break the interface. Anyway it's merged so @fabpot, anytime :)
Commits
-------
5b0f1da [HttpKernel] made WebTestCase methods static
Discussion
----------
[HttpKernel] made WebTestCase methods static
This makes it possible to load fixture data in `::setUpBeforeClass()` which makes tests run much faster.
Also, `createClient()` is not protected instead of public; I'm not sure why it was public in the first place.
Commits
-------
72c074a [Session] Used \Locale::setDefault() when the locale is setted
Discussion
----------
[Session] Used \Locale::setDefault() when the locale is setted
For `DateType` in form component (by example), `\Locale::getDefault()` is used to displayed the name of months.
If `\Locale` class is not used when the locale is setted in the session, the name of months is not in a good language.
This PR solves this problem.
---------------------------------------------------------------------------
by pborreli at 2011/05/29 09:13:44 -0700
what if user doesn't have intl extension ?
---------------------------------------------------------------------------
by stof at 2011/05/29 09:24:04 -0700
You should wrap the calls to ``\Locale::setDefault`` in a ``class_exist`` check to avoid issue when using the stub implementation (for which calling ``setDefault`` is forbidden).
---------------------------------------------------------------------------
by francisbesset at 2011/05/29 09:26:40 -0700
@pborreli: Symfony have a fake Locale class and this class is used only if the server haven't intl enabled.
---------------------------------------------------------------------------
by stof at 2011/05/29 09:33:16 -0700
@francisbesset Yeah, but ``setDefault`` throw a ``BadMethodCall`` exception.
and so the check has to use ``extension_loaded`` instead of ``class_exists``.
---------------------------------------------------------------------------
by fabpot at 2011/06/13 10:12:15 -0700
Ticket #1121 is related to this PR.
---------------------------------------------------------------------------
by fabpot at 2011/06/15 06:18:28 -0700
I have just tried another implementation where the locale is passed as an argument to the built-in types and some data transformers (via a `LocaleAwareInterface` interface). That works fine as forms are immutable now, but the solution is obviously more "complex" as we need to pass the locale to many different classes. Also, using `Locale::setDefault()` has an advantage over my method: you can change the locale whenever you want within a PHP process (which can be useful even if this is an edge case). Last, but not the least, if make sense to update the PHP Locale to the user locale.
So, to sum up, this patch is probably the best solution (easy and flexible enough).
Commits
-------
e8326aa Renamed attributes to attr to be consistent with templating.
c707467 Added support for additional attributes in Form types that list field as their parent.
Discussion
----------
[Form] Added support for additional attributes
Added support for additional attributes in Form types that list field as their parent.
This is needed particularity for html5 data and data- attributes support, unfortunately $options['data'] is already taken, so adding a general $options['attributes'] is the easiest solution without breaking BC.
Now I know that this will be tempting for some to stuck style and class attributes here also, but I'd rather not restrict the keys that are passed in.
---------------------------------------------------------------------------
by Seldaek at 2011/05/22 14:51:02 -0700
Maybe it should be called attr for consistency with the template stuff, or the other should be renamed attributes. Other than that, I'm +1, data-* attributes are awesome, and abusers will find ways to abuse things either way.
---------------------------------------------------------------------------
by mvrhov at 2011/05/22 21:48:01 -0700
Naming it attr also crossed my mind when I was signing off yesterday.
Along with the possibility to go the way xml attributes are handled when node is converted to/from array.
So every option with @ prefix would automatically become html attribute. However going the latter path, it'd be harder to implement.
---------------------------------------------------------------------------
by fabpot at 2011/06/13 07:43:52 -0700
Can you give an example of a real-world use case? Thanks.
---------------------------------------------------------------------------
by Seldaek at 2011/06/13 07:54:51 -0700
You can use `array('attr' => array('data-foo' => 'bar'))`, which will output `data-foo="bar"`, which can be read easily by jQuery for example as `$('el').data('foo')`. It's a standard compliant and elegant way to pass extra data needed by the JS code along with DOM nodes, without polluting everything with script tags and all.
---------------------------------------------------------------------------
by fabpot at 2011/06/13 08:01:08 -0700
@Seldaek: I understand that. But why not doing this in the template?
---------------------------------------------------------------------------
by Seldaek at 2011/06/13 08:04:10 -0700
Well, I agree it most likely belongs in the template, but it's kind of data stuff that is not directly impacting the display rules of the element, so in some cases having the possibility to set that from the php code might be useful. Anyway I'll let @mvrhov answer maybe he had a more concrete use case. I just think it's nice to leave the door open, but I don't really need it.
---------------------------------------------------------------------------
by mvrhov at 2011/06/13 10:27:03 -0700
A bit late to the party. Ok, here is my use-case.
I have a pretty large form where part of the data is of tabular form. The number of rows is almost every time a lot larger than the number of columns
So I can either output a lot of text inputs filled with data and make already a large form intimidating. Or I can use a grid that supports editing. So I serialize that tabular data as json and put it as a value into one hidden field. Somehow I also have to get the column definitions to that grid. I decided to I serialize it and put it inside data-* attribute. Putting it into another hidden field doesn't make sense as when data is submitted back I don't need the column definitions as only the number of rows changes.
---------------------------------------------------------------------------
by fabpot at 2011/06/13 10:44:58 -0700
@mvrhov: ok, but what prevents you from doing this in the template directly?
---------------------------------------------------------------------------
by mvrhov at 2011/06/13 11:22:53 -0700
I have to get it into the view somehow. What I'd really not like to do is, iterate through that data in a controller and then pass it as another template variable.
---------------------------------------------------------------------------
by fabpot at 2011/06/14 00:10:22 -0700
But the controller is where you prepare the data that you want to send to the view. Without any concrete example, I'm going to close this PR.
---------------------------------------------------------------------------
by mvrhov at 2011/06/14 01:21:10 -0700
IMHO this has to go out through form as this is the part of the form also I do have a very slim controllers in this case 10 LOC, where half of them is just setting up an view data..
Nonetheless I went looking again very closely at the AbstractType and I do have buildView function available which I can override and set the column data I need there, and then provide custom view for that, so at least from this part this is an non issue.
With this PR all default form attributes can be set from outside and when searching for a good use-case I have found out that @henrikbjorn has implemented this via extensions [1], maybe he has a good use-case for this.
[1] - https://github.com/Comways/ComwaysFormExtraBundle/blob/master/Form/Extension/FieldTypeExtension.php
---------------------------------------------------------------------------
by henrikbjorn at 2011/06/14 01:48:53 -0700
Convenience is the only use case
---------------------------------------------------------------------------
by stof at 2011/06/14 02:08:09 -0700
@fabpot The issue is that passing it from the controller as another template variable makes it really hard when you use the type twice with different values. Passing them from the form would be the easiest way
---------------------------------------------------------------------------
by shuogawa at 2011/06/14 19:37:50 -0700
hello. thanks for great form library.
I want to support two ways to display additional attributes for form elements.
1) control in template like
{{ form_row(form.name, { 'width': '30' }) }}
2) control from php
$builder->add('name', 'text', array('attr'=>array('width'=>'30')));
If form elements configure by end user like cms,
and form elements dynamically change.
The second method is useful.
template designer can write {{form_row(form)}}
but
template designer can not write {{form_row(form.name), { 'width': '30' }}}
Thank you
---------------------------------------------------------------------------
by fabpot at 2011/06/14 23:01:18 -0700
@shuogawa: That's what I fear. Setting the `width` or any other attribute in PHP is wrong. This belongs to the templates.
---------------------------------------------------------------------------
by stloyd at 2011/06/15 00:09:05 -0700
@fabpot Then maybe just restrict allowed tags to `data-*` and don't use `attr` but some other not confusing name ? Just like we do with i.e. `maxlength`.
---------------------------------------------------------------------------
by fabpot at 2011/06/15 04:44:25 -0700
I'm going to merge it as a "convenience" tool, but the documentation should clearly state that the only usage should be for `data-*` attributes.
Commits
-------
cdf4b6a Checked log levels
a45d3ee Reverted last commit
529381b ControllerNotFound: Changed log level from info to error. Also moved throw exception code block up, to prevent the message from beeing logged multiple times.
7c29e88 Changed log level of "Matched route ..." message from info to debug
dca09fd Changed log level of "Using Controller ..." message from info to debug
Discussion
----------
Log levels
Just wanted to ask if the log level INFO is still correct for these messages?
As there are only four log levels left (DEBUG, INFO, WARNING, ERROR), DEBUG might be the more appropriate level for these messages now.
Let me give an example: An application is logging user actions (maybe to database) in order to assure comprehensibility, e. g. "User %s deleted post %d", "User %s written a message to user %s". These are not warnings of course, so the only suitable log level is INFO.
But they will be thrown together with these very common (at least two per request?) "Using controller..." and "Matched route..." messages when choosing INFO as log level.
---------------------------------------------------------------------------
by Seldaek at 2011/05/24 07:13:18 -0700
Agreed, this stuff is framework debug information.
---------------------------------------------------------------------------
by fabpot at 2011/05/24 08:53:24 -0700
Why do you want to change these two specific ones? The framework uses the INFO level at other places too. Is it a good idea to say that the framework only logs with DEBUG?
---------------------------------------------------------------------------
by stof at 2011/05/24 09:12:53 -0700
Doctrine logs at the INFO level too and I think it is useful to keep it as INFO. Being able to see the queries without having all DEBUG messages of the event dispatcher and security components is useful IMO.
---------------------------------------------------------------------------
by Seldaek at 2011/05/25 02:30:24 -0700
Yeah, that's true, maybe we just need to reintroduce (again, meh:) NOTICE between INFO and WARNING.
@kaiwa Of course the other way could be that you just add your DB handler to the app logger stack. That could be done in a onCoreRequest listener or such, basically you'd have to call `->pushHandler($yourDBHandler)` on the `monolog.logger.app` service. That way your messages will flow to it, but it won't receive noise from the framework stuff since those log on monolog.logger.request and other log channels.
---------------------------------------------------------------------------
by fabpot at 2011/05/25 02:48:26 -0700
@Seldaek: I don't think we need another level. We just need to come up with a standard rules about the usage of each level. Adapted from log4j:
* ERROR: Other runtime errors or unexpected conditions.
* WARN: Use of deprecated APIs, poor use of API, 'almost' errors, other runtime that are undesirable or unexpected, but not necessarily "wrong" (unable to write to the profiler DB, ).
* INFO: Interesting runtime events (security infos like the fact the user is logged-in or not, SQL logs, ...).
* DEBUG: Detailed information on the flow through the system (route match, security flow infos like the fact that a token was found or that remember-me cookie is found, ...).
What do you think?
---------------------------------------------------------------------------
by stloyd at 2011/05/25 02:53:38 -0700
+1 for this standard (also this PR can be merged then), but we should review code for other "wrong" log levels usage (if everyone accept this standard)
---------------------------------------------------------------------------
by fabpot at 2011/05/25 02:55:07 -0700
I won't merge this PR before all occurrences of the logger calls have been reviewed carefully and changed to the right level.
---------------------------------------------------------------------------
by kaiwa at 2011/05/25 02:58:44 -0700
@fabpot: Just noticed these two occurring for every request in my log file. You are right, there are other places where this changes must be applied if we will change the log level.
@stof: Hmm, i see. It is not possible to set the logger separately for each bundle, is it? That maybe would solve the problem. If somebody is interested in seeing the queries, he could set the log handler level to DEBUG for doctrine bundle, but still use INFO for the framwork itself. Plus he could even define a different output file or a completely different handler.
I'm not sure if something like that is possible already (?) or realizable at all... just came into my mind.
---------------------------------------------------------------------------
by Seldaek at 2011/05/25 03:01:07 -0700
Just FYI, from Monolog\Logger (which has CRITICAL and ALERT):
* Debug messages
const DEBUG = 100;
* Messages you usually don't want to see
const INFO = 200;
* Exceptional occurences that are not errors
* This is typically the logging level you want to use
const WARNING = 300;
* Errors
const ERROR = 400;
* Critical conditions (component unavailable, etc.)
const CRITICAL = 500;
* Action must be taken immediately (entire service down)
* Should trigger alert by sms, email, etc.
const ALERT = 550;
The values kind of match http error codes too, 4xx are expected errors that are not really important (404s etc) and 5xx are server errors that you'd better fix ASAP. I'm ok with the descriptions, but I think alert and critical should be included too. I'll probably update Monolog docblocks to match whatever ends up in the docs.
---------------------------------------------------------------------------
by Seldaek at 2011/05/25 03:03:21 -0700
@kaiwa you can do a lot, but not from the default monolog configuration entry, I'm not sure if we can really make that fully configurable without having a giant config mess. Please refer to my [comment above](https://github.com/symfony/symfony/pull/1073#issuecomment-1234316) to see how you could solve it. Maybe @fabpot has an idea how to make this more usable though.
---------------------------------------------------------------------------
by stof at 2011/05/25 03:19:43 -0700
@Seldaek the issue is that the different logging channels are only know in the compiler pass, not in the DI extension. So changing the level in the extension is really hard IMO.
Thus, the handlers are shared between the different logging channels (needed to open the log file only once for instance, or to send a single mail instead of one per channel) and the level is handled in the handlers, not the logger.
I'm +1 for the standard, by adding the distinction between 400 and 500 status calls using ERROR and CRITICAL (which is already the case in the code).
@kaiwa do you have time to review the calls to the logger between DEBUG and INFO or do you prefer I do it ? For instance, the Security component currently logs all message at DEBUG level and some of them should be INFO.
---------------------------------------------------------------------------
by kaiwa at 2011/05/25 04:31:04 -0700
@stof ok i'll do that
---------------------------------------------------------------------------
by kaiwa at 2011/05/25 12:22:51 -0700
Need some help :) I came across `ControllerNameParser::handleControllerNotFoundException()` which leads to redundant log messages currently:
>[2011-05-25 20:53:16] request.INFO: Unable to find controller "AppBaseBundle:Blog" - class "App\BaseBundle\Controller\BlogController" does not exist.
>[2011-05-25 20:53:16] request.ERROR: InvalidArgumentException: Unable to find controller "AppBaseBundle:Blog" - class "App\BaseBundle\Controller\BlogController" does not exist. (uncaught exception) at /home/ruth/symfony3/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerNameParser.php line 87
Is it necessary to call `$this->logger->info($log);` if the InvalidArgumentException will be logged anyway?
---------------------------------------------------------------------------
by stof at 2011/05/25 12:39:22 -0700
Well, the issue is that the ControllerNameParser logs messages and then uses them to throw an exception. I guess the logging call should be removed as it is redundant with the one of the ExceptionListener. @fabpot thoughts ?
---------------------------------------------------------------------------
by kaiwa at 2011/05/27 11:39:25 -0700
I checked all debug, info and log calls. Sometimes it is hard to distinguish between the levels, so it would be great if someone reviews @cdf4b6a. @stof, maybe you want to take a look?
---------------------------------------------------------------------------
by kaiwa at 2011/05/31 12:52:07 -0700
@stof, thanks for your comments. I added some replies above, please let me know your suggestions.
---------------------------------------------------------------------------
by stof at 2011/05/31 14:04:22 -0700
@kaiwa As I said before, all the security logging calls should be DEBUG (most of them) or INFO (the one syaing that authentication succeeded for instance), but not WARN or ERROR as the exception don't go outside the firewall.
Commits
-------
07fa82d [Form] Revert changes impacting perfomance and readability
b709551 [Order] Make Form::types and FormView::types use the same order (Parent > Child)
e56dad6 [Form] simplify the code
bdd755e [Form] Fix the exception message when no block is found
c68c511 [Form] Make theming form prototypes consistent (start by looking for a '_<id>_<section>' block)
9ec9960 [Form] Simplify the code
4e3e276 [Form] Make the prototype view child of the collection view
Discussion
----------
[Form] Make the prototype view child of the collection view
This PR should be a base for discussion.
The [current implementation](https://github.com/symfony/symfony/pull/1188) has some drawbacks because the prototype view is not a child of the collection view:
* The 'multipart' attribute is not propagated from the prototype to the collection,
* The prototype view do not use the theme from the collection.
Those 2 points are fixed by the proposed implementation and one more benefit is that the template markup might be easier to work with:
before:
```html
<div id="form_emails">
<div>
<label for="form_emails_0">0</label>
<input type="email" id="form_emails_0" name="form[emails][0]" value="a@b.com">
</div>
<script type="text/html" id="form_emails_prototype">
<div>
<label for="$$name$$">$$name$$</label>
<input type="email" id="$$name$$" name="$$name$$" value="" />
</div>
</script>
</div>
```
after:
```html
<div id="form_emails">
<div>
<label for="form_emails_0">0</label>
<input type="email" id="form_emails_0" name="form[emails][0]" value="a@b.com">
</div>
<script type="text/html" id="form_emails_prototype">
<div>
<label for="form_emails_$$name$$">$$name$$</label>
<input type="email" id="form_emails_$$name$$" name="form[emails][$$name$$]" value="" />
</div>
</script>
</div>
```
@kriswallsmith I'd like to get your feedback on this PR. thanks.
---------------------------------------------------------------------------
by stof at 2011/06/14 07:01:01 -0700
@fabpot any ETA about merging it ? Using the prototype currently is a pain to build the name. The change makes it far easier
---------------------------------------------------------------------------
by fabpot at 2011/06/14 07:09:46 -0700
The templates are much better but I'm a bit concerned that we need to add the logic into the Form class directly. That looks quite ugly. If there is no other way, I will merge it.
---------------------------------------------------------------------------
by vicb at 2011/06/14 07:14:32 -0700
I have found no better way... I am testing some minor tweaks I want to submit.
---------------------------------------------------------------------------
by kriswallsmith at 2011/06/14 07:34:25 -0700
I'm not happy with the code in Form.php either... would creating a PrototypeType accomplish the same thing?
---------------------------------------------------------------------------
by vicb at 2011/06/14 07:42:07 -0700
@kriswallsmith tried and dismissed, the id and name are bad & you have to go for `render_widget(form.get('proto'))` in the template. That should be fixeable but not any better.
---------------------------------------------------------------------------
by kriswallsmith at 2011/06/14 07:45:21 -0700
What do you mean the id and name are bad? If we have a distinct type for the prototype, can't we do whatever we want using buildView() and the template?
---------------------------------------------------------------------------
by vicb at 2011/06/14 07:53:31 -0700
@kriswallsmith the id would be smthg like `form_emails_$$name$$_prototype` but yes we should be able to do whatever we want but the code might end up being more complex.
I am done with the tweaks but still open to feedback on this PR.
---------------------------------------------------------------------------
by kriswallsmith at 2011/06/14 08:08:21 -0700
Yes, that is the type of name I would expect.
---------------------------------------------------------------------------
by kriswallsmith at 2011/06/14 08:08:33 -0700
Oops -- I mean id.
---------------------------------------------------------------------------
by kriswallsmith at 2011/06/14 08:09:42 -0700
Maybe I'm confused what id you're referring to. I'll try to spend some time on this today.
---------------------------------------------------------------------------
by vicb at 2011/06/14 08:23:56 -0700
That should be the id of the `<input>`, the id of the script would be `form_emails_$$name$$_prototype_prototype` (if prototype is the name of the nested node).
I am trying to setup a branch with my code (playing with git & netbeans local history)
---------------------------------------------------------------------------
by vicb at 2011/06/14 08:46:25 -0700
@kriswallsmith https://github.com/vicb/symfony/tree/kris/proto if that can help (there are still changes in Form.php)
---------------------------------------------------------------------------
by kriswallsmith at 2011/06/14 08:47:08 -0700
Thanks, I'll take a look.
---------------------------------------------------------------------------
by vicb at 2011/06/15 00:48:38 -0700
I would have expected it to be faster however `array_map` is about twice slower... reverted !
Commits
-------
49dd558 Couple more CS fixes
5a986bf Add $keysCount & minor CS fix
91f4097 [Routing] Better nesting for RouteCollections in dumped URL matcher classes With this change, a route prefixed with '/blogger' will be nested inside '/blog' (for example)
Discussion
----------
[Routing] Better nesting for RouteCollections in dumped URL matcher classes
Consider the following routing file:
_blog:
resource: "@AcmeDemoBundle/Resources/config/routing/BlogController.yml"
prefix: /blog
_blogger:
resource: "@AcmeDemoBundle/Resources/config/routing/BloggerController.yml"
prefix: /blogger
_bloggeroo:
resource: "@AcmeDemoBundle/Resources/config/routing/BloggerooController.yml"
prefix: /bloggeroo
_blogtest:
pattern: /blogtest
defaults: { _controller: AcmeDemoBundle:Blog:test }
login:
pattern: /login
defaults: { _controller: AcmeDemoBundle:Security:login }
Note: Each imported file contains two simple blog/blogger/bloggeroo routes (e.g. blog_index & blog_view)
With this change, the cached URL matcher looks something like this:
```php
<?php
class appprodUrlMatcher
{
public function match($pathinfo)
{
$allow = array();
if (0 === strpos($pathinfo, '/blog')) {
// blog_index
if (preg_match('#^/blog/(?P<slug>[^/]+?)$#x', $pathinfo, $matches)) {...}
// blog_view
if (preg_match('#^/blog/(?P<year>\d{4})/(?P<month>\d{2})/(?P<slug>[^/]+?)$#x', $pathinfo, $matches)) {...}
if (0 === strpos($pathinfo, '/blogger')) {
// blogger_index
if (preg_match('#^/blogger/(?P<slug>[^/]+?)$#x', $pathinfo, $matches)) {...}
// blogger_view
if (preg_match('#^/blogger/(?P<year>\d{4})/(?P<month>\d{2})/(?P<slug>[^/]+?)$#x', $pathinfo, $matches)) {...}
if (0 === strpos($pathinfo, '/bloggeroo')) {
// bloggeroo_index
if (preg_match('#^/bloggeroo/(?P<slug>[^/]+?)$#x', $pathinfo, $matches)) {...}
// bloggeroo_view
if (preg_match('#^/bloggeroo/(?P<year>\d{4})/(?P<month>\d{2})/(?P<slug>[^/]+?)$#x', $pathinfo, $matches)) {...}
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
}
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
}
// _blogtest
if ($pathinfo === '/blogtest') {...}
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
}
// login
if ($pathinfo === '/login') {...}
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
}
}
```
As far as I can see, you can throw the 404 earlier (as I've done), as by nesting all these possibilities, there is no chance another route will be matched outside the parent if statement.
---------------------------------------------------------------------------
by stloyd at 2011/06/11 08:37:15 -0700
You should follow Symfony [CS rules] (http://symfony.com/doc/current/contributing/code/standards.html), also you should modify tests.
---------------------------------------------------------------------------
by lmcd at 2011/06/11 08:46:32 -0700
Besides the inline `continue` statement, I can't see spot any other CS violations. I'm on to the updated tests.
---------------------------------------------------------------------------
by fabpot at 2011/06/13 02:19:14 -0700
What if you have this:
_blog:
resource: "@AcmeDemoBundle/Resources/config/routing/BlogController.yml"
prefix: /blog
login:
pattern: /login
defaults: { _controller: AcmeDemoBundle:Security:login }
_blogger:
resource: "@AcmeDemoBundle/Resources/config/routing/BloggerController.yml"
prefix: /blogger
You cannot send 404 early because the same `blog` prefix is used in two different places. I can see many things that will break with this patch. I'm pretty sure we can enhance the performance of the existing code but let's do that after 2.0.
---------------------------------------------------------------------------
by lmcd at 2011/06/13 05:04:03 -0700
@fabpot: The code was designed so it would work in these kind of circumstances. I ran the dumper against the routing file you provided and this is the output below.
I see no reason why you can't throw the 404 earlier, as by nesting everything with similar prefixes, we're eliminating the possibility that a route will ever be matched outside of that if statement.
```php
public function match($pathinfo)
{
$allow = array();
if (0 === strpos($pathinfo, '/blog')) {
// blog_index
if (preg_match('#^/blog/(?P<slug>[^/]+?)$#x', $pathinfo, $matches)) {
...
}
// blog_view
if (preg_match('#^/blog/(?P<year>\d{4})/(?P<month>\d{2})/(?P<slug>[^/]+?)$#x', $pathinfo, $matches)) {
...
}
if (0 === strpos($pathinfo, '/blogger')) {
// blog_index
if (preg_match('#^/blogger/(?P<slug>[^/]+?)$#x', $pathinfo, $matches)) {
...
}
// blog_view
if (preg_match('#^/blogger/(?P<year>\d{4})/(?P<month>\d{2})/(?P<slug>[^/]+?)$#x', $pathinfo, $matches)) {
...
}
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
}
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
}
// login
if ($pathinfo === '/login') {
...
}
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
}
```
---------------------------------------------------------------------------
by fabpot at 2011/06/13 07:48:49 -0700
Can you add some more tests to ensure that everything works fine and that we won't have regressions later on? Thanks.
Commits
-------
e718474 fixed CS and unsude variable (PR #1319)
b552354 Executable Finder will now try to match if a file is already in the open_basedir list before searching it thru that list
Discussion
----------
open_basedir exhancements for Executable Finder
I've made the some changed to the Executable Finder in order to handle the open_basedir ability to specify files in the list not just directories.
This should fixsymfony/symfony#1319
Hope I didn't made any CS violations.
Commits
-------
9d6357c [HttpFoundation] Document the changes to the File classes
136b80a [HttFoundation] Add File::getExtension() as \SplFileInfo::getExtension() was introduced in PHP 5.3.6
38b3b74 [HttpKernel] Fix and test previous commit
ac0c00c [HttpFoundation] Make File extends \SplFileInfo
Discussion
----------
[HttpFoundation] Make File extends \SplFileInfo
This is a rebased version of [PR 674](https://github.com/symfony/symfony/pull/674).
* File: The API has changed (now extends \SplFileInfo),
* File: move() creates the target directory when it does not exist
* UploadedFile: introduction of getClientXXX() methods (for Size, OriginalName, MimeType)
If this PR does not get merged UploadedFile should at least be fixed: [Client.php](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/Client.php#L124) relies on a last parameter which is no more defined and which is used to bypass [move_uploaded_file()](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/File/UploadedFile.php#L155) in test mode.
If this could be merged, I'll detail the changes in UPDATE.md
---------------------------------------------------------------------------
by fabpot at 2011/06/14 08:20:59 -0700
I'll merge it. Can you update the UPDATE file?
---------------------------------------------------------------------------
by vicb at 2011/06/14 09:24:01 -0700
done
# Commits
ca52a04 [Validator] Allow DateTime objects as valid Times
# Discussion
## [Validator] Allow DateTime objects as valid Times
Also added tests for `DateTime` objects as valid on `Date` and `Time` constraints.
I didn't include the test for the `DateTime` constraint, as it's already included in this PR:
https://github.com/symfony/symfony/pull/1085
---------------------------------------------------------------------------
## fabpot @ 2011/06/09 09:07:21 -0700
I don't think it makes sense to use a \DateTime instance to represent a Time.
---------------------------------------------------------------------------
## ajessu @ 2011/06/09 09:33:20 -0700
If I have an entity with a doctrine type `Time`:
Time (DateTime instance where only H:i:s get persisted)
```php
<?php
/**
* @ORM\Column(type="time")
* @Assert\Time()
*/
protected $startTime;
```
and I create a form out of this Entity, a `DateTime` object is passed when the form is submitted.
This generates an `UnexpectedTypeException`.
I just made this change to match the `Date` validator with the doctrine type `Date`, which also shares this behavior:
https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator/Constraints/DateValidator.php#L28
Date (DateTime instance where only Y-m-d get persisted)
Rules are as follows:
* If multiple is true, then the empty_value is ignored
* If not, and if the field is not required, the empty_value is set to the empty string by default and displayed
* If the field is required, and if the user explicitely set the empty_value, then it is displayed
* kriswallsmith/form/collection-proto:
added script[type="text/html"] collection prototype to form themes
[Form] removed collection prototype from form tree
This reverts commit d044498cde.
The reason for reverting is that the name is actually used to customize
the template on a per field basis:
{% block _post_excerpt_widget %}
***{{ block('text_widget') }}***
{% endblock %}
Here, post is the name of the Type.
* theinterned/patch-1:
made logoutPath localizable as well
storing localized targetPath in a string as opposed to updating the attribute
In the spirit of 882a8e3f09 allow for localized logout target url
* kriswallsmith/form/lazier-csrf-token:
[Form] fixed xpath
[Form] moved csrf listener to its own class
fix issue with csrf token not present on collection fields because of resize listener
* lmcd/master:
$code referenced but not defined in compileRoute()
[Routing] Optimised the PHP URL matcher dumper The cached URL matcher classes contain some unneeded logic. Consider the following example:
The cached URL matcher classes contain some unneeded logic. Consider the following example:
if (0 === strpos($pathinfo, '/Blog')) {
// blog_index
if (0 === strpos($pathinfo, '/Blog') && preg_match('#^/Blog/(?P<slug>[^/]+?)$#x', $pathinfo, $matches)) {
return array_merge($this->mergeDefaults($matches, array ( '_action' => 'index',)), array('_route' => 'blog_index'));
}
}
The 2nd strpos is not required, as we have already satisfied this condition in the parent if statement.
My change will produce the following code for the same routing setup::
if (0 === strpos($pathinfo, '/Blog')) {
// blog_index
if (preg_match('#^/Blog/(?P<slug>[^/]+?)$#x', $pathinfo, $matches)) {
return array_merge($this->mergeDefaults($matches, array ( '_action' => 'index',)), array('_route' => 'blog_index'));
}
}
* lsmith77/serializer_tweaks: (22 commits)
clarified that BC is broken in the Serializer component
added UPDATE notes for Serializer component changes
fix tests
marked public api
more encoder lazy loading tweaks
always use getEncoder() to enable lazy loading
cosmetic tweak
removed setEncoder/removeEncoder/addNormalizer/removeNormalizer
SerializerAwareInterface and DecoderInterface do not implement EncoderInterface anymore
handle non objects
moved the methods that can later be moved to a Builder to the bottom
use getEncoder inside encode/decode
made serialize/deserialize/encode/decode final
added Constructor
added Exception's from SerializerBundle
made (de)normalizeObject() private
renamed hasEncoder/hasDecoder to supportsSerialization/supportsDeserialization
notice fixes
typo fixes
all encoders implement EncoderInterface
...
* lmcd/master:
Added an optimisation for PHP-FPM (FastCGI Process Manager). As soon as a full Response is dispatched to the browser, the HTTP connection is closed, but the script stays alive on FPM servers.
anything else is a total edge case that doesnt break with this change. it just means that for that edge case it will not be possible to "statically" determine if the encoder doesnt actually support encoding.
actually the main methods I am looking for is hasDecoder() and getEncoder() to be able to check if there is a Decoder to decode the Request body as well as if the encoder implements the TemplatingAwareInterface
The current implementation is not ready for inclusion in 2.0. It has several
known problems (security, not possible to disable it, not "cloud-compatible",
...) and it's not a must have feature anyway.
Some references:
* Security issue in FileType: https://github.com/symfony/symfony/issues/1001
* Validation fails on file, still stored in TemporaryStorage: https://github.com/symfony/symfony/issues/908
* Add a size argument & ability to configure TemporaryStorage: https://github.com/symfony/symfony/pull/748
This feature should be reworked and discussed for inclusion in 2.1.
This fixes choices when all the keys are strings (but integers really).
That's because in PHP, if you have the following array:
array('1' => 'foo', '2' => 'bar');
PHP "converts" it automatically to the following array:
array(1 => 'foo', 2 => 'bar');
* fivestar/single-choice-expanded:
[Form] Fixed FixRadioInputListener to not ignore 0.
[Form] Fixed single expanded choice type to set checked attribute when passed boolean value
* The command names have now full support for nested namespaces. It means
that abbreviations work for each sub-namespace:
./app/console doctrine:mapping:info
# worked before
./app/console doctrine:map:in
# works now
./app/console doc:map:in
* Aliases are now first class citizen. They can have their own namespace,
like the main name. So, now, there is no difference between an alias and a
name.
* As names and aliases can be namespaced, the Command::getFullName() and
Command::getNamespace() method have been removed.
Here are the new simplified rules:
* Required cache warmers are *always* executed when the Kernel boots for the first time;
* Optional cache warmers are *only* executed from the CLI via cache:warmup
These new rules means that all the configuration settings for the cache
warmers have been removed. So, if you want the best performance, remember to
warmup the cache when going to production.
This also fixed quite a few bugs.
* gordonslondon/http-foundation/response:
[HttpFoundation] merge Response::isRedirected() with Response::isRedirect() - Response::isRedirected() has been removed
* jwage/master:
Revert back to using gmmktime and use day 15 instead of 1 to avoid edge case
Use mktime instead of gmmaketime. On the 1st of every month the following options are generated:
* Also changed the default value of the calendar paramter to \IntlDateFormatter:GREGORIAN
in DateTimeToLocalizedStringTransformer which is the same as the default value in
StubIntlDateFormatter
<select id="filter_start_date_month" name="filter[start][date][month]">
<option value="1">Dec</option>
<option value="2">Jan</option>
<option value="3">Feb</option>
<option value="4">Mar</option>
<option value="5">Apr</option>
<option value="6" selected="selected">May</option>
<option value="7">Jun</option>
<option value="8">Jul</option>
<option value="9">Aug</option>
<option value="10">Sep</option>
<option value="11">Oct</option>
<option value="12">Nov</option>
</select>
I do not totally understand the problem but using mktime instead of gmmktime fixes the issue.
* vicb/form-rendering:
[Form] The variable stack should not persist between section rendering (fixes#1157)
[Twig][Form] Tweak form extension phpDoc and code
[Form] Tweak phpDoc
[FormView] fix phpDoc
[Form] Some tweaks
* Seldaek/events:
[EventDispatcher] Removed temporary code
[FrameworkBundle] Improved code readability
[FrameworkBundle] Clarified code and fixed regression
Update Core and Security events to latest model
[EventDispatcher] Allow registration of arbitrary callbacks
[EventDispatcher] Remove useless code
[EventDispatcher] Minor memory optimization to getListeners()
[FrameworkBundle] Small optimization, remove some function calls
* Chekote/xmlfileloader_overload_refactor:
Refactored the processing of each individual node into it's own method, enabling easier overloading of behavior for Bundles such as FriendsOfSymfony/RestBundle
* CodeMeme/1058-fix-radio-input-listener:
Fix for RadioInputListener's empty value erroneously becoming extra data Refs #1058
Added test for RadioInputListener bug treating no data as extra data
* stloyd/validators_refactoring:
Refactor validators constraints: - remove need for defining "getTargets()" method as 95% of validators use same one - replace abstract "Constraint::getTargets()" with one that use 95% of validators - add additional tests for "Constraint::getTargets()" method - remove unused "use" statement in Constraint\Valid
* maoueh/date_type_dead_code:
[Form] Removed dead code in the buildForm method of DateType.php * With the introduction of the getAllowedOptionValues mechanics, the check is performed prior to the buildForm call. There is no more needs to check it again in DateType.
The main benefit is that in XML/YML files we have common syntax (i.e. core.controller, form.pre_bind) that properly namespaces event names (before: onCoreController was ok, preBind was not).
On the other hand in PHP land we also have namespaced events, CoreEvents::controller, FormEvents::preBind, before it was Events::onCoreController, Events::onPreBind, we now have more context.
This in effect removes the direct link between event name and the method name on the handler.
Any callback can be given as a handler and the event name becomes an arbitrary string. Allowing for easier namespacing (see next commit)
- remove need for defining "getTargets()" method as 95% of validators use same one
- replace abstract "Constraint::getTargets()" with one that use 95% of validators
- add additional tests for "Constraint::getTargets()" method
- remove unused "use" statement in Constraint\Valid
* everzet/builder-private-services-fix:
[DependencyInjection] create inlined private service from it's definition
[DependencyInjection] added failing private service user test-case
The current code was broken when a style was defined inline:
<bg=black>Foo</bg=black>
When creatin a new style formatter, it's better to let the formatter
apply the style to the text.
* With the introduction of the getAllowedOptionValues mechanics, the check
is performed prior to the buildForm call. There is no more needs to check
it again in DateType.
* beberlei/YamlRoutingLoader:
[Routing] Remove exception condition in YamlFileLoader::load() as its duplicating a check that is done in parseRoute() anyways. This changes allows to extend the YamlFileLoader without having to duplicate the whole method.
* schniper/patch-2:
Fix process creation under Win7 Ultimate (app/console assetic:dump ./web): - Set the default $env to NULL, thus inheriting the system's environment settings (array() is no good). - Set bypass_shell to false, otherwise process creation will fail (I don't know if this should happen only on Win7)
- Set the default $env to NULL, thus inheriting the system's environment settings (array() is no good).
- Set bypass_shell to false, otherwise process creation will fail (I don't know if this should happen only on Win7)
* bschussek/form: (22 commits)
Fix merge error (function "guess" was in there twice)
[Form] Added test case for bf2f9d2a02
[Form] Form::isBound() and Form::isValid() work correctly now for read-only forms
[Locale] Improved error reporting and added stubs for intl_is_failure(), intl_get_error_code() and intl_get_error_message()
[Form] Implemented fix for 361c67f54f
[Form] Add test for the handling of array values in the constraint violation
[Form] Further simplified PropertyPath code
[Form] Added test for 6c337d1cc0
[Form] Removed unused option "pattern" of date and time type
[Form] Renamed view variable "name" to "full_name"
[Form] Renamed collection option "type_options" to "options" to be consistent with the repeated type
[Form] CSRF documentation and a few CS changes
[Form] Move CSRF options from types to the CSRF extension
[Form] Added a search form field type
[Form] Optimization of PropertyPath
[Form] replace assertEquals by assertFalse, assertTrue, assertNull
[Form] fix file permissions to 644 again ;)
[Form] add tests for type_options in collectionType
fix file permissions to 644
[Form] add type_options for CollectionType to be abble to set options to type
...
* beberlei/DoctrineUniqueValidator:
[Doctrine] Fix default value to null for entity manager to make fluent integration with Doctrine Registry work
[Doctrine] Add fields as default option and allow strings to be passed.
[Doctrine] Add DoctrineBundle integration (DI Container registration) for the UniqueEntityValidator
[Doctrine] Implement suggested changes by Stof, added functional test to verify unique validator works.
[Doctrine] Add Unique Validator
This type of override is supported by MS MVC3 and is recommended by Google.
Also added ability to override request method via ?_method= when
request is made via GET.
* stof/ParameterBagInterface:
[DependencyInjection] Removed the public keyword from interface
[DependencyInjection] Added missing methods in the ParameterBagInterface
[DependencyInjection] Fixed phpdoc
* alexandresalome/feat-routing-exceptions:
[Routing] Fix the exception inheritance + Add the LICENCE block in new files
[Routing] Change the Exception namespacing + base class for every exception + update PHPDoc
[Routing] Add specific exceptions for the UrlGenerator
* stloyd/ipvalidator_fix:
Better comment about no test IP6 addresses for "FILTER_FLAG_NO_RES_RANGE"
Refactoring of IpValidator to use native php filter extension, also adding additional flag support and test cover.
* kreischweide/master:
[Process] Workaround for windows based stderr bug
[Process] Wrong descriptor mode for stderr
Fixed wrong descriptor mode for stderr
Notice: Undefined index: _flash in /var/www/test/symfony2/vendors/symfony/src/Symfony/Component/HttpFoundation/Session.php on line 231
Warning: array_key_exists() expects parameter 2 to be array, null given in /var/www/test/symfony2/vendors/symfony/src/Symfony/Component/HttpFoundation/Session.php on line 231
* Chekote/firefox_put_fix:
Fixed content type for urlencoded forms being too specific. For example, this will now function will clients (such as Firefox) that append the charset to the content type header. Uses 0 === strpos() as per @kriswallsmith suggestion.
* bschussek/form_validator:
[Form] Renamed the value "text" of the "widget" option of the "date" type to "single-text"
[Form] Implemented getAllowedOptionValues() for core types
[Form] Removed unused option
[Form] Added FormTypeInterface::getAllowedOptionValues() to better validate passed options
[Form] Improved test coverage of FormFactory and improved error handling
[Form] Added getType() to FormFactoryInterface
[Validator] Refactoring DateTimeValidator and DateValidator
[Validator] Date: check if the value is a DateTime instance
When generating URL, thrown exceptions are InvalidArgumentException and
distinction of errors is quite difficult. This modification brings different
exceptions for different cases
encoding is detected using the `mb_detect_encoding()`-function
in strict-mode. Checking is done before the parsing starts.
Without this patch, the calls to `preg_replace()` using the
'u'-modifier would cause the non-utf8-string being processed
to be empty when parsing starts which makes the parsing return
no result.
* danielholmes/functional_test_changes:
[FrameworkBundle] fixed CS
[FrameworkBundle][HttpKernel] added a default tearDown on the WebTestCase which will shut down the currently used kernel (if there is one) in Web functional tests
* schmittjoh/security:
[HttpFoundation] fixed php doc
updated UPDATE file
[Security] use deep flag when retrieving username + password
[HttpFoundation] added $deep flag to Request::get()
[HttpFoundation] removed getDeep(), added a boolean flag to get() instead
* vicb/form-fixes:
[Form] Make the PropertyPathMapper class use the UnexpectedTypeException
[Form] Fix adding transformers in the FormBuilder
[Form] Fix the ReversedTransform class
Usage:
$formBuilder = $this->get('form.factory')
->createBuilder('form');
$formBuilder->setAttribute('validation_constraint', new Callback(array("methods"=>array(
'validate' => function ($data, $context) use ($elements) {
// logic to add violations depending on the elements
}
))));
* schmittjoh/security:
[HttpFoundation] added unit test
[Security][HttpFoundation] splits Request::hasSession() into hasSession(), and hasPreviousSession()
[SecurityBundle] added some tests
add provider to configuration
update DI to handle change in config and another provider
separate dbal specific acl config
add provider to configuration
update DI to handle change in config and another provider
separate dbal specific acl config
If you use the MinLength validator with your entities, the ValidatorTypeGuesser gets the value, stored as "minlength". Then, the FormFactory generates a "pattern" attribute out of minlength and maxlength.
Modern browsers such as Chrome use this attribute to validate the form before submitting.
a "pattern" attribute is generated that validates the
* bschussek/form:
[Form] CSRF fields are not included in the children of a FormView anymore if the view is not the root
[Form] FormView::offsetUnset() is now supported. It was possible anyway using getChildren() and setChildren().
[Form] Split the option "modifiable" of the "collection" type into "allow_add" and "allow_delete"
[Form] Added test for last commit by kriswallsmith and improved dealing with original names
[Form] Fixed variable scope when entering nested form helpers
[Form] Added tests for blocks/templates in the format _<ID>_(widget|row|label|...)
[Form] updated listener to check that data is an array
The form component should now guarantee to always pass an UploadedFile object to your model. There you can call getOriginalName() to retrieve the original name of the uploaded file. For security reasons, the real file name is a generated hash value.
This allows people to filter easily between 404 type of responses (that are mostly for users) and real errors in their application (where they probably want to get an email notification
This feature added complexity to the framework but wasn't used in the core anyway.
You can still use the Map class loader in your application though. But most of the time, using the APC
autoloader is just better.
* kriswallsmith/kernel/bundle-extension:
[HttpKernel] added check of default extension alias convention
[AsseticBundle] coding standard and comment tweaks
[HttpKernel] added BundleInterface::getContainerExtension() which is implicitly loaded
* Brouznouf/patch-2:
[Serializer] [XmlEncoder] Add unit test for decoding / encoding root with attributes
[Seriliazer] [XmlEncoder] Optimize conditions
[Serializer] [XmlEncoder] Allow decoder to extract attributes in root element
This has been removed for several reasons:
* the framework does not know where the document root is and should not care
* as the document root was static, it was impossible to have several document roots depending on some business rules (see next one)
* sometimes, the document root is not under the web root directory (so the logic of getWebPath() is not always correct)
* the feature was not used anywhere in the core
* markchalloner/master:
[Validator] Updated ContraintViolationList ArrayAccess setter to check equivalence to null instead of using is_null
Implemented ArrayAccess interface
I've made the change as the executable goal is to find the executable. The fact that it does not find it is
part of the contract and it is not exceptional.
* igorw/ipv6:
[HttpFoundation] minor optimization
minor adjustments suggested by vicb
[HttpFoundation] IPv6 support for RequestMatcher
[HttpFoundation] refactor RequestMatcherTest to use dataProvider
[Validator] use full iPv6 regex
[Validator] add IPv6 support to UrlValidator
[HttpFoundation] add IPv6 support to Request
[HttpFoundation] test Request::create with an IP as host name
[HttpFoundation] refactor Request::getClientIp test
* dustinwhittle/master:
[Classloader] Added phpdoc with example usage + refactored unit tests fixtures
[Classloader] Refactored ApcUniversalClassLoader to use setUp() to detect APC
[Classloader] Fixed typo + coding standards in ApcUniversalClassLoader test
[Classloader] Fixed APC class loader + added unit tests
* bschussek/form:
[Form] Automatically setting "data_class" option if objects are passed at the creation of a form
[Form] Improved the way passed data is handled in FormFactory
[Form] Simplified FileType code
[HttpFoundation] TemporaryStorage automatically creates the directory if it doesn't exist yet
[Form] Changed FormBuilder::build() to FormBuilder::create(). You hvae to pass the resulting builder to FormBuilder::add() manually now
[Form] Added FieldTypeValidatorExtension and fixed FQCN of DelegatingValidator
* weaverryan/form_tweaks:
[Form] Removing an unused variable in TimeType
[Form] Throwing exception for invalid "input" type of DateType
[Form] Removing unused private property and adding PHPDoc
[Form] Fixing wrong variable name
[Form] Tweak to FileTypeTest to avoid warning
[Form] Adding an exception for an invalid widget option in DateType
* bschussek/form-extensions:
[Form] Refactored code from CoreExtension to new ValidatorExtension
[Form] Added FormTypeExtensionInterface
[Form] Reorganized code into "form extensions"
With implementations of this interface, existing types can be amended.
The Csrf extension, for example, now contains a class FormTypeCsrfExtension
that adds CSRF capabilities to the "form" type.
To register new type extensions in the DIC, tag them with "form.type_extension"
and the name of the extended type as alias.
The extension classes are now the only constructor argument of the FormFactory class. They replace the existing "type loader" classes.
new FormFactory(array(
new CoreExtension($validator, $storage),
new CsrfExtension($csrfProvider),
new DoctrineOrmExtension($em),
));
Together with a few upcoming commits this mechanism will make
* extension of the form framework in bundles and
* usage of the forms outside of Symfony2
much easier.
* lsmith77/request_format_tweaks:
added text/html to default format mapping
return "q" from splitHttpAcceptHeader() to enable more complex accept header negotiations
added support for setting a custom default format in Request::getRequestFormat()
* made the options array only for "global" options that are valid for all session storages
* changed the PDO session storage constructor signature to accept an array of options for DB configuration
* changed the storage_id to be the full service id, instead of just part of it
* removed the class parameter for session as it can be changed via the .class parameter (it was the only example in the framework)
* removed the configuration for the PDO session storage for now
The data can now be passed to all creation methods:
$form = $factory->create('form', $data);
By default, a form will receive the name of its type ("form" in above example). If you wish to pass a custom name, use createNamed():
$form = $factory->createNamed('form', 'myform', $data);
* form: (291 commits)
[FrameworkBundle] updated method call
[Form] Removing excess option in the TimezoneType
[FrameworkBundle] Adding check for invalid form type for better exception message
[TwigBundle] Removing dbug text in form template
[Form] Removed obsolete code in TextType
[Form] fixed translations escaping
[Form] Adding a check that the choice_list option on the ChoiceType implements the ChoiceListInterface.
[Form] added support for groups in form validation (when using array data)
[Form] fixed error bubbling for choices when expanded is true
[Form] added a unit test
[Form] Removed obsolete view variables
[Form] Renamed ChoiceUtil to FormUtil and gave its methods more general names
[Form] Changed separator for Twig blocks from double underscore to single underscore to match the PHP template separator
[Form] Removed StripTagsListenerTest
[Form] Removed StripTagsListener. Its implementation is insufficient and needs to be replaced by a better one.
[Form] added a way to specify the form constraint when building the form (useful if you work with arrays instead of objects)
[Form] Added test for 'email' type and fixed a few bugs
[Form] Removed obsolete constraints from validation.xml
Revert "[Form] removed validation.xml file (not used anymore)"
Added html5 email input to the forms
...
* Infranology/framework-bundle-updated-method-call: (91 commits)
[FrameworkBundle] updated method call
moved DoctrineMongoDBBundle to its own repository
[AsseticBundle] fixed unit tests
[FrameworkBundle] removed unneeded files in tests
updated vendors
[FrameworkBundle] removed the need to boot a Kernel in a unit test file
[FrameworkBundle] removed the need to boot a Kernel in a unit test file
[Routing] added getContext() accessor
[HttpFoundation] fixed a potential security problem in Request
updated vendors
Added 201 to the possible status codes that indicate a response is a redirect.
[FrameworkBundle] made ESI URL relative as allowed by the spec (no need to generate absolute URLs)
[AsseticBundle] fixed router and controller
[AsseticBundle] removed fake front controller from URL before creating route
[AsseticBundle] updated twig integration to check debug mode at runtime rather than compile time since twig cannot vary its cache by debug mode
[Routing] the global parameters must not be added in the QS when generating URLs
removed the possibility to pass a message to the trans tag
simplified exceptions as Twig is now smart enough to automatically add line information
made the %count% variable automatically available when using the transchoice filter (similar to how the tag works)
[Container] Added function array_unique on getServiceIds to return only one service name
...
* schmittjoh/referenceValidation:
[DependencyInjection] also check references of inlined services
[DependencyInjection] adds emulation of "exception-on-invalid-reference" behavior
* schmittjoh/security:
[Security/Core] force implementations to accept null values
[Security/Acl] some misc fixes
[Security/Acl] removed Doctrine dependency from interfaces and moved them to the actual implementation
[SecurityBundle] changed expected value for token_provider key in the rememberme section
* kriswallsmith/dic/method-renames:
added method renames to UPDATE
[DependencyInjection] renamed ContainerBuilder::remove() as removeDefinition() to be more consistent with other definition-related methods
[DependencyInjection] renamed Definition::setArgument() as replaceArgument() to be more specific
The _scheme requirement can be used to force routes to always match one given scheme
and to always be generated with the given scheme.
So, if _scheme is set to https, URL generation will force an absolute URL if the
current scheme is http. And if you request the URL with http, you will be redirected
to the https URL.
* lsmith77/add_decoder_interface:
added a DecodeInterface (and SerializerAwareInterface) to make it easier to identify if an Encoder also supports decoding
* hidenorigoto/feature/add-server-param-method:
[BrowserKit] added tests for setServerParameter/getServerParameter methods
[BrowserKit] added getServerParameter method which makes setServerParameters/setServerParameter methods testable
[BrowserKit] added the method to Client which enables to set single server parameter
[Form] Fixed {get,set,has}Var references in templating php
[Form] Added getVars to FormView to ease usage in Twig. Also added some phpdoc and cleaned up the get method by adding a default value
[Form] Fix
[Form] Delete file generated by test
Based on dfb93b1bcebf1f34d3a880d00f36acb2bcca0f08:
[FORM] Fixed DateField Month Choices
The month choices were calculated using the current day of the month with
gmmktime rather than the 1st of the month. Additionally, this provides a
UTC timestamp which is passed to the formatter (IntlDateFormatter) which
converts the timestamp using the current timezone. This means that the UTC
timestamp for 1st March was being converted for my timezone (EST) and giving
a date of 28th February, leading to Feb appearing again in the popup form
instead of Mar.
* schmittjoh/diLogging:
[DependencyInjection] enable debug related passes only in debug environment
[DependencyInjection] removed pass time
[DependencyInjection] fixes a bug which might have occurred when using property injection under certain circumstances
[DependencyInjection] fixed method name
[FrameworkBundle] whitespace fix
[DependencyInjection] refactored code a bit, added some more logging messages
[DependencyInjection] dump a readable format
[DependencyInjection] better logging
* hhamon/http_cache_fix:
[HttpKernel] private $traces property was not initialized to an empty array. When using the getLog() method to debug traces, it led to a warning in the apache error log.
* Funsational/master:
Update PDO session storage to check if any rows are updated when doing a session write. If no rows are udpated when performing a session write it generally means that we have created a new session id somewhere and we have not inserted into the database. This is the case for when calling regenerate_session_id() from the native session storage class. It will update the session id then call sessionWrite() to save the session but since the new session id does not exist in the DB, no rows are updated and any new session attributes such as security tokens are lost.
* vicb/event_debug:
[FrameworkBundle] Make some TraceableEventDispacther properties private
[Event] Tweak phpDoc for consistency
[FrameworkBundle] Add error detection to the TraceableEventDispatcher
Moving the template context creation makes sense and allows for simpler code for the end user:
Before:
return array('post' => $post, 'form' => $this->get('form.factory')->createTemplateContext($form));
After:
return array('post' => $post, 'form' => $form->getContext());
* Brouznouf/master:
[Serializer] Revert DOMElement to SimpleXmlElement
[Serializer] Using DOMElement instead of SimpleXmlElement in XmlEncoder to permit some behavior
* hason/logicalname:
[Templating] changed __toString method (synonym for getLogicalName method)
[Templating] fixed phpdoc a test
[FrameworkBundle] added getLogicalName() method to TemplateReference
[Templating] added method to return the template logical name, added test
* vicb/config_base:
[Config] Add a note about the ConfigurationInterface interface in UPDATE.md
[MonologBundle] Make The Configuration class implements the ConfigurationInterface
[Config] Introduction of an ConfigurationInterface
* vicb/resource_path:
Update for Bundle names long again (= include the 'Bundle' suffix)
[Kernel] Make locateResource() throws an exception when a resource from a Bundle hides a custom resource
[Kernel] Make resources overriding consistent across bundle directories and resource directories
[Kernel] Improve test semantic
[Kernel] Update tests with shorter bundle names
[Kernel] Restore the tests for the locateResource method
Resource paths should use the full bundle name (with the 'Bundle' postfix)
* Seldaek/serializer:
[Serializer] Some more privates
[Serializer] Move private methods below protected ones
[Serializer] Added @api annotations
[Serializer] Added docblocks for NormalizableInterface
[Serializer] add methods to the SerializerInterface
[Serializer] Added docblock
[Serializer] Switched most protected to private or final
* weaverryan/prevent_exception_on_handle_exception:
[HttpKernel] Wrapping the end of handleException() in a try-catch to prevent response listeners from throwing another exception
* weaverryan/better_import_exception_and_bug_fix:
[Config] Improving the exception when a resource cannot be imported
[DependencyInjection] Fixing a bug where "ignore_errors" doesn't work in YAML and XML
This improves, for example, the exception one would receive if they tried to import a resource from a bundle that doesn't exist.
Previously, the deep "bundle is not activated" exception would be thrown. That has value, however there is no indication of where
the exception is actually occurring.
In this new implementation, we throw an exception that explains exactly which resource, and from which source resource, cannot be
loaded. The deeper exception is still thrown as a nested exception.
Two caveats:
* The `HttpKernel::varToString` method was replicated
* This introduces a new `Exception` class, which allows us to prevent lot's of exceptions from nesting into each other in the case
that some deeply imported resource cannot be imported (each upstream import that fails doesn't add its own exception).
* hason/frameworkbundle:
[HttpKernel] removed unused class
[FrameworkBundle] fixed bugs
[FrameworkBundle] fixed test on windows
[FrameworkBundle] fixed CS
* kriswallsmith/kernel/shorter-bundle-names:
updated codebase to use shorter bundle names
[HttpKernel] updated component to work with shorter bundle names
[HttpKernel] updated Bundle::getName() to validate bundle class name and rtrim "Bundle"
If PHP_PATH is not defined (default)
PHP_BINDIR is used to guess exe, but on windows this constant seems to be hardcoded and doesn't point to the good folder
So before to throw an error we check if PEAR is installed, most of the case it is, and it will have good php bin path for sure.
The problem was that "data_class" was used in two places: FormBuilder::build() and PropertyPathMapper.
PropertyPathMapper was already constructed during FormType::buildForm(), so any data class changes made to the FormBuilder wouldn't affect the data class of the PropertyPathMapper anymore and so lead to an inconsistent state.
* schmittjoh/security:
changed condition nesting
[Security] ACL: AclVoter::vote only gets an ObjectIdentity if $object is not an instance of ObjectIdentityInterface
[SecurityBundle] fixed missing argument EventDisplatcher in RememberMe service
* kriswallsmith/framework/protocol-relative-base-urls:
[Templating] updated assets helper to leave protocol-relative URLs untouched
[FrameworkBundle] cleaned up test class
Quote from HTTP (bis) spec (Part 2 - 5.1.1):
The Reason Phrase exists for the
sole purpose of providing a textual description associated with the
numeric status code, out of deference to earlier Internet application
protocols that were more frequently used with interactive text
clients. A client SHOULD ignore the content of the Reason Phrase.
* subsven/master:
re-add filename based directory filter to the AnnotationDirectoryLoader, now restricting to *.php files and therefore disregarding e.g. SVN metadata files
revert adding filename based filter to the directory resource
Eleminate the need to manually clear the cache if a new controller file containing routing annotations is added - part II * add unit tests * introduce filename filter to DirectoryResource (to restrict change monitoring to a subset of files) * modify AnnotationDirectoryLoader.php to use filename filter set on Controller\.php$
* add unit tests
* introduce filename filter to DirectoryResource (to restrict change monitoring to a subset of files)
* modify AnnotationDirectoryLoader.php to use filename filter set on Controller\.php$
* vicb/cfg_rebase:
[Config] Ability to add and override node types without having to subclass NodeBuilder
[DoctrineBundle] Fix some typos
[SwiftMailerBundle] Fix a merge issue in the configuration
Tweak PHPDocs in the extension configuration files
[Config] Component refactoring
* The array returned by getListeners() now removes the listener hash as the key (as this is an implementation detail)
* The sort method now guarantees that a listener registered before another will stay in the same order even for the same priority (for BC)
* Made various optimizations
* events:
[FrameworkBundle] fixed the traceable event manager
[EventDispatcher] made order deterministic (first registered one stay first) -- this makes the new system more compatible with the old one
[FrameworkBundle] fixed class loading order
fixed various bugs introduced during the event system migration
renamed filterCore* to onCore*
fixed CS
fixed phpdoc
renamed some methods in the event dispatcher
[HttpKernel] Removed unused onCoreSecurity event
[Security] Fixed method names in the Firewall listeners
[HttpKernel] Added more code documentation to the HttpKernel events
[Security] Fixed method calls on EventDispatcher
[FrameworkBundle] Removed EventSubscriber support for DI tags because it currently cannot be implemented
[Security] Fixed calls to EventDispatcher::dispatchEvent()
Switched from Doctrine's EventManager implementation to the EventManager clone in Symfony2 (now called EventDispatcher again)
[EventDispatcher] Replaced EventDispatcher by Doctrine's implementation
Renamed EventArgs classes and adapted remaining code to EventManager
Replaced EventDispatcher by Doctrine's EventManager implementation
The onCore* events are fired at some pre-defined points during the
handling of a request. At this is more important than the fact
that you can change things from the event.
The Config component API have changed and the extension configuration files must be updated accordingly:
1. Array nodes must enclosed their children definition in ->children() ... ->end() calls:
Before:
$treeBuilder->root('zend', 'array')
->arrayNode('logger')
->scalarNode('priority')->defaultValue('INFO')->end()
->booleanNode('log_errors')->defaultFalse()->end()
->end();
After:
$treeBuilder->root('zend', 'array')
->children()
->arrayNode('logger')
->children()
->scalarNode('priority')->defaultValue('INFO')->end()
->booleanNode('log_errors')->defaultFalse()->end()
->end()
->end()
->end();
2. The 'builder' method (in NodeBuilder) has been dropped in favor of an 'append' method (in ArrayNodeDefinition)
Before:
$treeBuilder->root('doctrine', 'array')
->arrayNode('dbal')
->builder($this->getDbalConnectionsNode())
->end();
After:
$treeBuilder->root('doctrine', 'array')
->children()
->arrayNode('dbal')
->append($this->getDbalConnectionsNode())
->end()
->end();
3. The root of a TreeBuilder is now an NodeDefinition (and most probably an ArrayNodeDefinition):
Before:
$root = $treeBuilder->root('doctrine', 'array');
$this->addDbalSection($root);
public function addDbalSection(NodeBuilder $node)
{
...
}
After:
$root = $treeBuilder->root('doctrine', 'array');
$this->addDbalSection($root);
public function addDbalSection(ArrayNodeDefinition $node)
{
...
}
4. The NodeBuilder API has changed (this is seldom used):
Before:
$node = new NodeBuilder('connections', 'array');
After:
The recommended way is to use a tree builder:
$treeBuilder = new TreeBuilder();
$node = $treeBuilder->root('connections', 'array');
An other way would be:
$builder = new NodeBuilder();
$node = $builder->node('connections', 'array');
Some notes:
- Tree root nodes should most always be array nodes, so this as been made the default:
$treeBuilder->root('doctrine', 'array') is equivalent to $treeBuilder->root('doctrine')
- There could be more than one ->children() ... ->end() sections. This could help with the readability:
$treeBuilder->root('doctrine')
->children()
->scalarNode('default_connection')->end()
->end()
->fixXmlConfig('type')
->children()
->arrayNode('types')
....
->end()
->end()
* everzet/console-privatisation-errors:
if we moved definition under private area, than we need to use only public API for that, to be able to redefine it is subclasses
start => finish, begin => end. Mixing them is a bad choice.
ability to define custom regex's for style placeholders
we need ability to get style parameters same way we set them with setStyle
sometimes, developers like me want to redefine style placeholders
in their applications. From this patch, they can acchieve this from
simple get...Regex() method redefine.
from last privatisation update $styles now private. So,
user can set style with public setter (setStyle), but can't
get this value later, which is very stupid behavior!
* kriswallsmith/classloader/optimizations:
[ClassLoader] added an apc class loader
[ClassLoader] created protected findFile() method to allow creating a cache layer via inheritance
[ClassLoader] added a check before trimming the leading \
* kriswallsmith/dic/false-circular-ref-fix:
[DependencyInjection] fixed false positive when detecting circular references if a service throws an exception during creation
* kriswallsmith/dic/lazy-replace-ext-params:
[DependencyInjection] added test for lazy param replacement
Removed replacement of parameter placeholders at load time since they're now replaced at compile time. Extensions should be written to expect parameter placeholders.
Changes on the Router to avoid array_diff, array_keys and other inneficient array_ functions.
This is a "recommit" to respect Symfony Contribution rules
* opensky/hotfix/test_client:
[HttpKernel] added test for uri change
[HttpKernel] got rid of url transformation into uri, as parse_url doesn't work with uris
* Seldaek/file_field:
[HttpFoundation] Fixed test breaking on windows
[HttpFoundation] UploadedFile::getOriginalName is now overriding getName
[HttpFoundation] Minor optimization
[Form] Add exception for missing enctype attribute
* fixes a problem with security (/foo/bar and /foo///bar are not the same URL as far as security is concerned)
* this can still be done in your web server configuration or by adding a core.request listener
* kriswallsmith/dic/lazy-compiler:
[DependencyInjection] made compiler lazy again since there are many temporary ContainerBuilder objects that don't use it
in your routing configuration, only existing files in this directory
get tracked for changes in this directory. So if you add a new
controller file in this directory you'd have to manually clear the
cache since the new file gets ignored.
This patch adds a DirectoryResource for this case which tracks all
changes in the given directory (and files and directories contained
within).
The only missing part is ContainerAwareEventManager::addEventSubscriberService(),
because I'm not sure how to find out the class name of a service in the DIC.
Also, inline documentation of this code needs to be finished once it is accepted.
* hhamon/cookie_path_fix:
[Security] renamed Cookie::isHttponly() to Cookie::isHttpOnly()
[HttpKernel] renamed Cookie::isHttponly() to Cookie::isHttpOnly()
[BrowserKit] renamed Cookie::isHttponly() to Cookie::isHttpOnly()
[HttpFoundation] fix cookie path default value to / and added some new unit tests to cover the class
* DuoSRX/code-coverage:
[HttpFoundation] Fixed a typo in response->setLastModified()
[HttpFoundation] Added some more tests on response
[HttpFoundation] Added some tests on Response
[HttpFoundation] Replace a duplicated test with a method in Response
Fixed code coverage generation when resources folder are deeper
* jakzal/FileLocatorTest:
[Config] Added missing tests to satisfy 100% test coverage of FileLocator. Made sure that every path returned with locate() is unique.
* digitalkaoz/httpkernel-debug:
[HttpKernel] added tests for debug stuff
[HttpKernel] reset handling if subject::handle throws an exception, otherwise it wouldnt be able to handle furthermore
* schmittjoh/security:
[Security] forward the entire access denied exception instead of only the message
[Security] changed defaults for MessageDigestEncoder
TICKET #9557: session isn't required when using http basic authentification mecanism for example
[Security] improved entropy to make collision attacks harder
[Security] added the 'key' attribute of RememberMeToken to serialized string to be stored in session
Fix the Acl schema generator script.
Added support for the full range of escaped values in double quoted
strings in chapter 5 of the YAML 1.1 and 1.2 specs. The escaping
and unescaping strategies were factored out into separate classes to
keep the logic isolated.
Added examples from the spec to the unit tests for all escaped values.
Doctrine's EventManager implementation has several advantages over the
EventDispatcher implementation of Symfony2. Therefore I suggest that we
use their implementation.
Advantages:
* Event Listeners are objects, not callbacks. These objects have handler
methods that have the same name as the event. This helps a lot when
reading the code and makes the code for adding an event listener shorter.
* You can create Event Subscribers, which are event listeners with an
additional getSubscribedEvents() method. The benefit here is that the
code that registers the subscriber doesn't need to know about its
implementation.
* All events are defined in static Events classes, so users of IDEs benefit
of code completion
* The communication between the dispatching class of an event and all
listeners is done through a subclass of EventArgs. This subclass can be
tailored to the type of event. A constructor, setters and getters can be
implemented that verify the validity of the data set into the object.
See examples below.
* Because each event type corresponds to an EventArgs implementation,
developers of event listeners can look up the available EventArgs methods
and benefit of code completion.
* EventArgs::stopPropagation() is more flexible and (IMO) clearer to use
than notifyUntil(). Also, it is a concept that is also used in other
event implementations
Before:
class EventListener
{
public function handle(EventInterface $event, $data) { ... }
}
$dispatcher->connect('core.request', array($listener, 'handle'));
$dispatcher->notify('core.request', new Event(...));
After (with listeners):
final class Events
{
const onCoreRequest = 'onCoreRequest';
}
class EventListener
{
public function onCoreRequest(RequestEventArgs $eventArgs) { ... }
}
$evm->addEventListener(Events::onCoreRequest, $listener);
$evm->dispatchEvent(Events::onCoreRequest, new RequestEventArgs(...));
After (with subscribers):
class EventSubscriber
{
public function onCoreRequest(RequestEventArgs $eventArgs) { ... }
public function getSubscribedEvents()
{
return Events::onCoreRequest;
}
}
$evm->addEventSubscriber($subscriber);
$evm->dispatchEvent(Events::onCoreRequest, new RequestEventArgs(...));
* kriswallsmith/dic/auto-ext-load:
[HttpKernel] added an subclass merge extension configuration compiler pass to ensure each bundle's "main" extension is loaded
[DependencyInjection] extensions should only load if called during configuration
You can now modify set or bound data by adding a filter for either of the following events:
* Filters::filterBoundDataFromClient
* Filters::filterBoundData
* Filters::filterSetData
Instead, hidden fields now override the "row" template to not include a label or errors.
The "rest" (former "hidden") helper has been adapted to output any fields that were not
rendered manually. It should usually be called at the end of a form.
Fields are not available in the templates anymore. Instead, all required information can be
accessed through view variables.
Example usage of helpers and variables in a form theme:
// use the label helper
{{ this.label('my label') }}
// use the label variable
{{ this.vars.label }}
{{ label }}
Example usage of helpers and variables in a normal template:
// use the label helper
{{ field.label('my label') }}
// use the label variable
{{ field.vars.label }}
Change 3e818846 in doctrine/dbal introduced a number of new classes in
the Doctrine\DBAL\Platforms\Keywords namespace, so we need to be more
careful here when generating Acl schema, so as to only load Platform
classes and not any others in the same directory.
* schmittjoh/security:
[Security] added method to retrieve the configured remember-me parameter
[Security] Copy token attributes when auth providers create a new token from another
* cristiangsp/Translation_FallbackLocale:
[Translation] Modified Translation unit test "testTransWithFallbackLocale"
[Translation] Fixed the addition of the fallbackLocale catalogue to the current locale catalogue.
[Translation] Added search to FallbackLocale Catalogue.
When loading a catalogue the function "optimizeCatalogue" add the fallback catalogue to the current locale catalogue. This should be done by first adding the language catalogue and finally adding the fallbacklocale catalogue specified in the configuration. This subsequent additions are done by the "loadCatalogue" function.
The problem is that in the "loadCatalogue" function exists an if statement that checks if the resource of a given locale exists before loading it. If not, the function simply returns. This return implies that the subsequent addition of the fallbacklocale wouldn't be done.
This has been fixed by simply replacing the current if statement and adding a new one that, if the resource exists, then executes the process of resource loading. Finally, the function continue calling the "optimizeCatalogue" function.
When the current locale catalogue doesn't contain the id searched, the code doesn't search in the fallbacklocale catalogue (as is explained in the documentation).
Added the search to the fallbacklocale catalogue to the translation function.
PreAuthenticatedAuthenticationProvider and UserAuthenticationProvider tend to copy a token instead of modifying it during their authenticate() methods, which is probably a good idea if the token might be immutable. Ensure that the token's attributes get copied along with everything else.
You can enable the stubs by including the following code in app/autoload.php:
$loader->registerPrefixFallback(array(
__DIR__.'/../vendor/symfony/src/Symfony/Component/Locale/Resources/stubs',
));
If the intl extension is not loaded, the stub classes for the "en" locale
will be created automatically.
The Response is not available in the DIC anymore.
When you need to create a response, create an instance of
Symfony\Component\HttpFoundation\Response instead.
As a side effect, the Controller::createResponse() and Controller::redirect()
methods have been removed and can easily be replaced as follows:
return $this->createResponse('content', 200, array('foo' => 'bar'));
return new Response('content', 200, array('foo' => 'bar'));
return $this->redirect($url);
return Response::createRedirect($url);
Without this patch, if you call __toString() on a Response,
the content-type auto-detection would never be trigerred
as __toString() changes the default content-type.
This allows for configuration options that must accept arbitrary variables. Even if the node's value is an array, VariableNode will not perform any special processing/merging as is done for ArrayNode. It functionally behaves like a ScalarNode.
As these files are just about optimizing the performance,
they are now part of the sandbox and the upcoming standard
Symfony distribution.
It should also make your IDE happier!
* weaverryan/config_definition_changes:
[SecurityBundle] Allowing the main Configuration tree to allow "factories" without a validation exception.
[SecurityBundle] Removing an old configuration key in a test - caught by the Configuration validation.
[SecurityBundle] Adding the ignoreExtraFields option to the factories tree so that there aren't validation errors on all the other unknown fields.
[Config] Adding an ignoreExtraKeys options, which allows you to let options simply be ignore without throwing a validation exception.
[Config] Reverting some meaningless changes that are no longer needed to minimize the true diff of the changes. Increasing the test precision.
[Config] Reverting the preventExtraKeys option. This is a revert of functionality that would have allowed "unnamed" children to be added to an array node.
[Config] Moving the removal of the key attribute on ArrayNode onto the setKeyAttribute() method per Johannes.
[Config] Renaming the key attribute removal property for consistency per Johannes' recommendation. Also fixing a PHPDoc typo per Stof.
[SwiftmailerBundle] Removing unnecessary "enabled" key in a test.
[FrameworkBundle] Removing the "namespace" key when it's defined in its own weird location in XML. This prevents that key, which we move in this same location, from looking like an invalid option during validation.
[Config] Renaming NodeBuilder::nodeBuilder() to NodeBuilder::builder() due to the fact that PHP can get confused when you have a __construct() method *and* a method that has the same name as the class (looks like two constructors to PHP).
[Config] Making the option to remove a key attribute optional.
[Config] Renaming the NodeBuilder::addNodeBuilder() to simply NodeBuilder::nodeBuilder() to be consistent with the other names: node(), arrayNode().
[Config] Making changes per the recent movement of the Config builder into the Config component.
[DependencyInjection] Renaming allowUnnamedChildren to preventExtraKeys. Also moved the place where validation of extra configs occurs.
[DependencyInjection] Being sure to remove XML-remapped singular options and key attribute options after processing.
[DependencyInjection] Adding a NodeBuilder::addNodeBuilder() method that helps achieve a fluid interface when a pre-built NodeBuilder needs to be added.
[DependencyInjection] Initial implementation of an allowUnnamedChildren method on NodeBuilder. Also added an "extra field" exception.
I had thought that this was unnecessary - when would you ever want to just let "extra" options fail silently?
But, the SecurityExtension takes advantage of this by creating two separate config trees. The first tree looks for just one particular value on the configuration array and ignores the rest. So, there *is* a use-case for allowing all extra fields to simply be ignored, though this should not be the norm.
We decided that this is not necessary and that it's leaving too many things wide open. Instead, in these cases where we have an array with unknown items, a prototype should be used.
Further functionality will need to be added later to allow you to specify a few nodes that you *do* know about under an array and then also specify a prototype to catch everything else.
This is *usually* what you want (and is defaulted this way). If you have an entry in an array *just* so it can become the key to that entry later, then you shouldn't normally still need it in the resulting array.
The importance of this comes in with validation. Since we're throwing an exception if you have any unrecognized options, the presence of the "key" field in the resulting array will cause issues when it's not needed.
This commit breaks functional tests in Symfony\Component\HttpKernel\HttpCache\HttpCacheTest.php. I tried to fix functional tests but I didn\'t manage to. For your information, the "try { } catch" block in the HttpKernel\HttpCache::lookup() method seems strange because I suspect line 274 to never leverage any exception...
Fixes a bug in `Bundle::registerCommands` with console commands in sub-directories of `Command`. `MyBundle\Command\FooCommand` worked great, but with `MyBundle\Command\Bar\BazCommand` Bundle would try to register `MyBundle\CommandBar\BazCommand` instead.
Note that this commit removes the built-in support for MongoDB user providers.
This code can be moved back in once there is a stable release for MongoDB, but
for now you have to set-up that user provider just like you would set-up any
custom user provider:
security:
providers:
document_provider:
id: my.mongo.provider
How to upgrade?
For XML configuration files:
* All extensions should now use the config tag (this is just a convention as
the YAML configurations files do not use it anymore):
* The previous change means that the doctrine and security bundles now are
wrapped under a main "config" tag:
<doctrine:config>
<doctrine:orm />
<doctrine:dbal />
</doctrine:config>
<security:config>
<security:acl />
...
</security:config>
For YAML configuration files:
* The main keys have been renamed as follows:
* assetic:config -> assetic
* app:config -> framework
* webprofiler:config -> web_profiler
* doctrine_odm.mongodb -> doctrine_mongo_db
* doctrine:orm -> doctrine: { orm: ... }
* doctrine:dbal -> doctrine: { dbal: ... }
* security:config -> security
* security:acl -> security: { acl: ... }
* twig.config -> twig
* zend.config -> zend
This allows for better conventions and better error messages if you
use the wrong configuration alias in a config file.
This is also the first step for a bigger refactoring of how the configuration
works (see next commits).
* Bundle::registerExtensions() method has been renamed to Bundle::build()
* The "main" DIC extension must be renamed to the new convention to be
automatically registered:
SensioBlogBundle -> DependencyInjection\SensioBlogExtension
* The main DIC extension alias must follow the convention:
sensio_blog for SensioBlogBundle
* If you have more than one extension for a bundle (which should really
never be the case), they must be registered manually by overriding the
build() method
* If you use YAML or PHP for your configuration, renamed the following
configuration entry points in your configs:
app -> framework
webprofiler -> web_profiler
doctrine_odm -> doctrine_mongo_db
In routing files, import statements allow an optional "type" option to hint the resources' type (e.g. for ambiguous file extensions). This adds the same type option to the FrameworkExtension config, which defines the main routing resource.
XML/YAML loaders assume imported resources are files before attempting to resolve their loader. This is problematic for loaders such as Assetic, which does not use a file as its resource. Furthermore, the previous consecutive calls to both locate() and getAbsolutePath() were redundant. File location can safely be delayed until FileLoader::import(), and we can let that throw an exception if the file is not found.
This reverts commit f53080860a.
Revert "[Router] config fixes"
This reverts commit 51beecc6f2.
Revert "moved duplicated files to a new Config component"
This reverts commit a8ec9b27f0.
Rules are :
- If one of the ESI has validation cache strategy, the whole page will be
forced to validate.
- In none of the ESI has validation, the response will feature a Cache-Control
directive with s-maxage value equals to the smallest TTL of ESIs.
The merging is done in three steps:
1. Normalization:
=================
All passed config arrays will be transformed into the same structure
regardless of what format they come from.
2. Merging:
===========
This is the step when the actual merging is performed. Starting at the root
the configs will be passed along the tree until a node has no children, or
the merging of sub-paths of the current node has been specifically disabled.
Left-Side Right-Side Merge Result
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-nothing- array Right-Side will be taken.
scalar scalar Right-Side will be taken.
array false Right-Side will be taken if ->canBeUnset()
was called on the array node.
false array Right-Side will be taken.
array array Each value in the array will be passed to
the specific child node, or the prototype
node (whatever is present).
3. Finalization:
================
The normalized, and merged config will be passed through the config tree to
perform final validation on the submitted values, and set default values
where this has been requested.
You can influence this process in various ways, here is a list with some examples.
All of these methods must be called on the node on which they should be applied.
* isRequired(): Node must be present in at least one config file.
* requiresAtLeastOneElement(): PrototypeNode must have at least one element.
* treatNullLike($value): Replaces null with $value during normalization.
* treatTrueLike($value): Same as above just for true
* treatFalseLike($value): Same as above just for false
* defaultValue($value): Sets a default value for this node (only for scalars)
* addDefaultsIfNotSet(): Whether to add default values of an array which has not
been defined in any configuration file.
* disallowNewKeysInSubsequentConfigs(): All keys for this array must be defined
in one configuration file, subsequent
configurations may only overwrite these.
* fixXmlConfig($key, $plural = null): Transforms XML config into same structure
as YAML, and PHP configurations.
* useAttributeAsKey($name): Defines which XML attribute to use as array key.
* cannotBeOverwritten(): Declares a certain sub-path as non-overwritable. All
configuration for this path must be defined in the same
configuration file.
* cannotBeEmpty(): If value is set, it must be non-empty.
* canBeUnset(): If array values should be unset if false is specified.
Architecture:
=============
The configuration consists basically out of two different sets of classes.
1. Builder classes: These classes provide the fluent interface and
are used to construct the config tree.
2. Node classes: These classes contain the actual logic for normalization,
merging, and finalizing configurations.
After you have added all the metadata to your builders, the call to
->buildTree() will convert this metadata to actual node classes. Most of the
time, you will not have to interact with the config nodes directly, but will
delegate this to the Processor class which will call the respective methods
on the config node classes.
This commit removes CollectionToStringTransformer. Transformers should never change the state of the outside world, otherwise hard-to-track bugs might creap in.
This functionality needs to be implemented as a custom FieldType (see EntityChoiceField).
The implication is that set<Reference>() in the object of the parent form will not be called (and thus not has to be implemented/public).
If you want to suppress this behaviour, manually set "by_reference" to false.
Previously, the Definition class was used both for type inference and factory construction (if factoryService was absent). This is fine for cases where classes create instances of themselves (e.g. getInstance() or create()), but leads to ambiguity when we have a separate factory class.
Separated validation of data and form had serious drawbacks. When a form had nested form whose data was not connected to the data of the root form, this data would not be validated.
The new implementation validates the whole object graph at once. Class Form has a new method validateData(), that manually passes the data to the GraphWalker of the Validator and overrides the Default group with the groups set in the form.
This is mainly intended for complex configurations to ease the work you
have with normalizing different configuration formats (YAML, XML, and PHP).
First, you have to set-up a config tree:
$treeBuilder = new TreeBuilder();
$tree = $treeBuilder
->root('security_config', 'array')
->node('access_denied_url', 'scalar')->end()
->normalize('encoder')
->node('encoders', 'array')
->key('class')
->prototype('array')
->before()->ifString()->then(function($v) { return array('algorithm' => $v); })->end()
->node('algorithm', 'scalar')->end()
->node('encode_as_base64', 'scalar')->end()
->node('iterations', 'scalar')->end()
->end()
->end()
->end()
->buildTree()
;
This tree and the metadata attached to the different nodes is then used
to intelligently transform the passed config array:
$normalizedConfig = $tree->normalize($config);
With the form factory there was no reasonable way to implement instantiation of custom form classes. So the implementation was changed to let the classes instantiate themselves. A FormContext instance with default settings has to be passed to the creation method. This context is by default configured in the DI container.
$context = $this->get('form.context');
// or
$context = FormContext::buildDefault();
$form = MyFormClass::create($context, 'author');
If you want to circumvent this process, you can also create a form manually. Remember that the services stored in the default context won't be available then unless you pass them explicitely.
$form = new MyFormClass('author');
A form now always has to be bound, independent of whether the request is a POST request or not. The bind() method detects itself whether the request was a post request or not and reads its data accordingly. The "old" bind()/isBound() methods were renamed to submit()/isSubmitted().
$form = new Form('author');
$form->bind($request, $author);
if ($form->isValid()) {
// isValid() implies isSubmitted(), non-submitted forms can
// never be valid
// do something with author now
}
Alternatively, you can only bind global variables, if you don't have a request object.
$form->bindGlobals($author);
Note that the $author object is in both cases optional. You can also pass no object at all and read the data using $form->getData(), but then no validation will occur. You can also prefill the form with an object during instantiation.
$form = new Form('author', array('data' => $author));
$form->bind($request);
// etc.
The Request constructor no longer uses values from PHP's super globals. If you want a Request populated with these values you must use the new static method Request::fromGlobals().
Your front controllers (i.e. web/app.php, web/app_dev.php ...) will need to be updated:
// old
$kernel->handle(new Request())->send();
// new
$kernel->handle(Request::fromGlobals())->send();
A class in Symfony2 can be loaded by four different mechanisms:
* bootstrap.php: This file contains classes that are always required and
needed very early in the request handling;
* classes.php: This file contains classes that are always required and
managed by extensions via addClassesToCompile();
* MapFileClassLoader: This autoloader uses a map of class/file to load
classes (classes are managed by extensions via addClassesToAutoloadMap(),
and should contain often used classes);
* UniversalAutolaoder: This autoloader loads all other classes (it's the
slowest one).
The three notification methods do not return the Event instance anymore.
notify() does not return anything
notifyUntil() returns the returned value of the event that has processed the event
filter() returns the filtered value
Upgrading your listeners:
Listeners for notify() and filter() events: nothing to change
Listeners for notifyUntil() events:
Before:
$event->setReturnValue('foo');
return true;
After:
$event->setProcessed();
return 'foo';
If you notify events, the processing also need to be changed:
For filter() notifications: the filtered value is now available as
the returned value of the filter() method.
For notifyUntil() notifications:
Before:
$event = $dispatcher->notifyUntil($event);
if ($event->isProcessed()) {
$ret = $event->getReturnValue();
// do something with $ret
}
After:
$ret = $dispatcher->notifyUntil($event);
if ($event->isProcessed()) {
// do something with $ret
}
* Added empty_value option on CountryField, LanguageField, LocaleField, TimezoneField
* Added missing date_pattern to DateTimeField
* Made the currency option on MoneyField required.
To benefit from the optimization, you need to change this line from your
autoload.php:
require_once $vendorDir.'/symfony/src/Symfony/Component/HttpFoundation/UniversalClassLoader.php';
to this one:
require_once $vendorDir.'/symfony/src/Symfony/Component/HttpKernel/bootstrap.php';
Notice that if you don't do this change, your app will in fact be slower than before.
Cache warmer will come in the next commits.
To warm up the cache on a production server, you can use
the cache:warmup command:
./app/console_prod cache:warmup
* The register() method on all listeners has been removed
* Instead, the information is now put directly in the DIC tag
For instance, a listener on core.request had this method:
public function register(EventDispatcher $dispatcher, $priority = 0)
{
$dispatcher->connect('core.response', array($this, 'filter'), $priority);
}
And this tag in the DIC configuration:
<tag name="kernel.listener" />
Now, it only has the following configuration:
<tag name="kernel.listener" event="core.response" method="filter" priority="0" />
The event and method attributes are now mandatory.
I believe the empty_value option is just a leftover Django-style option for what value the field should have if left blank. I don't see this doing anything and find no reference to anything like it anywhere else.
The separator option functionality is currently handled as a parameter in the field render functions. I think this should be moved to an option on the field, but this reflects teh current functionality (i.e. this option is not used).
This adds lazy loading for firewall configurations. This is useful when you have multiple firewalls, only the firewalls which are actually needed to process the Request are initialized. So, your event dispatcher is not as costly to initialize anymore.
It also implements re-using of RequestMatchers if all matching rules are the same, and exposes the remaining rules which are already implemented by the request matcher (host, ip, methods) in the access-control section
Before I explain the changes, let's talk about the current state.
Before this patch, the registerBundleDirs() method returned an ordered (for
resource overloading) list of namespace prefixes and the path to their
location. Here are some problems with this approach:
* The paths set by this method and the paths configured for the autoloader
can be disconnected (leading to unexpected behaviors);
* A bundle outside these paths worked, but unexpected behavior can occur;
* Choosing a bundle namespace was limited to the registered namespace
prefixes, and their number should stay low enough (for performance reasons)
-- moreover the current Bundle\ and Application\ top namespaces does not
respect the standard rules for namespaces (first segment should be the
vendor name);
* Developers must understand the concept of "namespace prefixes" to
understand the overloading mechanism, which is one more thing to learn,
which is Symfony specific;
* Each time you want to get a resource that can be overloaded (a template for
instance), Symfony would have tried all namespace prefixes one after the
other until if finds a matching file. But that can be computed in advance
to reduce the overhead.
Another topic which was not really well addressed is how you can reference a
file/resource from a bundle (and take into account the possibility of
overloading). For instance, in the routing, you can import a file from a
bundle like this:
<import resource="FrameworkBundle/Resources/config/internal.xml" />
Again, this works only because we have a limited number of possible namespace
prefixes.
This patch addresses these problems and some more.
First, the registerBundleDirs() method has been removed. It means that you are
now free to use any namespace for your bundles. No need to have specific
prefixes anymore. You are also free to store them anywhere, in as many
directories as you want. You just need to be sure that they are autoloaded
correctly.
The bundle "name" is now always the short name of the bundle class (like
FrameworkBundle or SensioCasBundle). As the best practice is to prefix the
bundle name with the vendor name, it's up to the vendor to ensure that each
bundle name is unique. I insist that a bundle name must be unique. This was
the opposite before as two bundles with the same name was how Symfony2 found
inheritance.
A new getParent() method has been added to BundleInterface. It returns the
bundle name that the bundle overrides (this is optional of course). That way,
there is no ordering problem anymore as the inheritance tree is explicitely
defined by the bundle themselves.
So, with this system, we can easily have an inheritance tree like the
following:
FooBundle < MyFooBundle < MyCustomFooBundle
MyCustomFooBundle returns MyFooBundle for the getParent() method, and
MyFooBundle returns FooBundle.
If two bundles override the same bundle, an exception is thrown.
Based on the bundle name, you can now reference any resource with this
notation:
@FooBundle/Resources/config/routing.xml
@FooBundle/Controller/FooController.php
This notation is the input of the Kernel::locateResource() method, which
returns the location of the file (and of course it takes into account
overloading).
So, in the routing, you can now use the following:
<import resource="@FrameworkBundle/Resources/config/internal.xml" />
The template loading mechanism also use this method under the hood.
As a bonus, all the code that converts from internal notations to file names
(controller names: ControllerNameParser, template names: TemplateNameParser,
resource paths, ...) is now contained in several well-defined classes. The
same goes for the code that look for templates (TemplateLocator), routing
files (FileLocator), ...
As a side note, it is really easy to also support multiple-inheritance for a
bundle (for instance if a bundle returns an array of bundle names it extends).
However, this is not implemented in this patch as I'm not sure we want to
support that.
How to upgrade:
* Each bundle must now implement two new mandatory methods: getPath() and
getNamespace(), and optionally the getParent() method if the bundle extends
another one. Here is a common implementation for these methods:
/**
* {@inheritdoc}
*/
public function getParent()
{
return 'MyFrameworkBundle';
}
/**
* {@inheritdoc}
*/
public function getNamespace()
{
return __NAMESPACE__;
}
/**
* {@inheritdoc}
*/
public function getPath()
{
return strtr(__DIR__, '\\', '/');
}
* The registerBundleDirs() can be removed from your Kernel class;
* If your code relies on getBundleDirs() or the kernel.bundle_dirs parameter,
it should be upgraded to use the new interface (see Doctrine commands for
many example of such a change);
* When referencing a bundle, you must now always use its name (no more \ or /
in bundle names) -- this transition was already done for most things
before, and now applies to the routing as well;
* Imports in routing files must be changed:
Before: <import resource="Sensio/CasBundle/Resources/config/internal.xml" />
After: <import resource="@SensioCasBundle/Resources/config/internal.xml" />
Now that we have a compilation phase for the DIC, using tags after compilation
is not needed anymore.
Tags were introduced to allow several independant bundles to be able to
interact which each others (remember that each extension knows nothing about
the others).
But during the compilation phase, the container has been merged ans so, all
the information from all bundles are available. This is then the right place
to deal with tags. That way, less work is needed at runtime and the DIC class
in the cache is also much smaller.
For simple cases, it means that you need to process the tag in a compiler pass
and store the information you need in a DIC parameter (have a look at the
TranslatorPass for a very simple example).
So, the PHP dumper does not add tags to the dumped PHP class anymore (it does
not implements TaggedContainerInterface anymore). But tags are still available
on ContainerBuilder instances.
Let's take some examples to explain the change.
First, if you don't use any vendored bundles, this commit does not change anything.
So, let's say you use a FooBundle from Sensio. The files are stored under Bundle\Sensio\FooBundle.
And the Bundle class is Bundle\Sensio\FooBundle\SensioFooBundle.php.
Before the change, the bundle name ($bundle->getName()) would have returned 'FooBundle'.
Now it returns 'SensioFooBundle'.
Why does it matter? Well, it makes template names and controller names easier to read:
Before:
Template: Sensio\FooBundle:Bar:index.twig.html
Controller: Sensio\FooBundle:Bar:indexAction
After
Template: SensioFooBundle:Bar:index.twig.html
Controller: SensioFooBundle:Bar:indexAction
NB: Even if the change seems simple enough, the implementation is not. As finding
the namespace from the bundle class name is not trivial
NB2: If you don't follow the bundle name best practices, this will probably
leads to unexpected behaviors.
* better separation of concerns
* made TwigBundle independant of the PHP Engine from FrameworkBundle (WIP)
* removed one layer of abstraction in the Templating component (renderers)
* made it easier to create a new Engine for any templating library
* made engines lazy-loaded (PHP engine for instance is not started if you only use Twig)
* reduces memory footprint (if you only use one engine)
* reduces size of compiled classes.php cache file
* made the renderer argument of Storage ctor mandatory
* refactored the Engine class to avoid code duplication
* simplified the check for a template that extends another one but with a different renderer
- inline private services which are references multiple times, but where all references originate from the same definition
- bug fix for non-shared services which were considered shared within the scope in which they were inlined
The current `loadClass()` implementation tries to load a class from the first matching prefix then stops, producing false-negative results. This is especially evident in groups of related libraries, such as Doctrine:
Doctrine
Doctrine\Common
Doctrine\Common\DataFixtures
Doctrine\DBAL
Doctrine\DBAL\Migrations
Each of these libraries is submoduled into a different vendor directory. Depending on what order these libraries are added to a UniversalClassLoader instance, classes may or may not actually be loaded. This fix continues searching registered namespaces and prefixes if the first partial match is negative.
These helpers have been removed as they do not work as expected.
Among other things, the order is not the right one when using PHP
templates, and adding assets from an included template is not
possible when using Twig templates.
This should be replaced by integrating a third-party library that
manages assets: minification, compilation, packaging, ...
If a user was not authenticated and visited the logout path, a null value was passed to the handler's logout() method, resulting in a catchable fatal error.
If the option is true, the password is never written into the input field's value. If it is false, it is only written into the input field's value after submitting a form with errors.
The default value for "always_empty" is true.
The semantics of property paths are now:
(1) if a property path is set, it is _always_ respected (relative to the object
of the parent field)
(2) if no property path is set, the object of the parent field is _always_ ignored
Fact (2) allows us to set data into fields that is updated independently of the parent
field (like CSRF tokens, subforms with different objects etc.)
What is missing now is support for subfields that pass the object of the parent field
through to their own subfields. This functionality would be needed for GoogleMapFields,
DateRangeFields etc., which are compositions of individual fields that update the
parent object of the FieldGroup.
There are several alternatives for the latter functionality that should be discussed
in a RFC.
Original explanation from pull request:
I'm Using symfony2 with URL Rewriting to 'hide' index.php.
On form authentication, symfony2 redirect to http://host:port/index.php/login_path instead of http://host:port/login_path. I do understand that, in my case, redirect is set into one of :
FormAuthenticationEntryPoint with getUriForPath()
FormAuthenticationListener with getUriForPath()
Security/Firewal/ExceptionListener with getUri()
This path modify getUri and getUriForPath to :
remove default port from URI
remove script name if not initially present
- interfaces can now also be defined on containers which are built with an Extension
- interface injection can also be used on classes that require constructor arguments
Currently, ambiguities only arise for PHP files, as PhpFileLoader and AnnotationFileLoader would both claim support. Future conflicts may occur if the XML, YAML, or PHP loaders were to receive Directory and Glob loaders (as annotations have).
Since the "type" parameter is optional, loader resolution will default to awarding resolution to the first loader to claim support. A previous hack in PhpFileLoader to avoid an AnnotationFileLoader conflict was removed, so that should be the only lost backwards compatibility with this patch. Unit tests were also created for the various loader classes, although only the supports() method is being tested.
This implementation was proposed on the symfony-dev mailing list in response to Fabien's RFC for custom loader notation: http://groups.google.com/group/symfony-devs/browse_thread/thread/3104c1a9e45799d2/20fbe393c1afe088
Both HttpKernel and Security define a 403 exception:
* Symfony\Component\HttpKernel\Exception\ForbiddenHttpException
* Symfony\Component\Security\Exception\AccessDeniedException
The one in HttpKernel has been removed in favor of the Security one.
Previously, HttpKernel performed request-stashing. By moving this to the Kernel class, the request is now available immediately after the kernel becomes aware of it. If the kernel is allowed to boot lazily (during the first call to handle()), this also allows an actual master Request to be available during booting.
The old "request" service definition (with a bogus class name) can be replaced with a factory-aware definition that retrieves the request directly from the kernel.
The original HttpKernel class can be deleted, as it's request-stashing will be moved to the Kernel class. FrameworkBundle's list of compiled classes must also be modified to respect this change.
To keep language consistent, three methods were changed in InputOption:
* `InputOption::acceptParameter()` -> `InputOption::acceptValue()`
* `InputOption::isParameterRequired()` -> InputOption::isValueRequired()`
* `InputOption::isParameterOptional()` -> `InputOption::isValueOptional()`
The InputDefinition::asXml() method was also modified to update the `accept_value` and `is_value_required` attributes.
When an object has a "main" many relation with related "things" (objects,
parameters, ...), the method names are normalized:
* get()
* set()
* all()
* replace()
* remove()
* clear()
* isEmpty()
* add()
* register()
* count()
* keys()
The classes below follow this method naming convention:
* BrowserKit\CookieJar -> Cookie
* BrowserKit\History -> Request
* Console\Application -> Command
* Console\Application\Helper\HelperSet -> HelperInterface
* DependencyInjection\Container -> services
* DependencyInjection\ContainerBuilder -> services
* DependencyInjection\ParameterBag\ParameterBag -> parameters
* DependencyInjection\ParameterBag\FrozenParameterBag -> parameters
* DomCrawler\Form -> FormField
* EventDispatcher\Event -> parameters
* Form\FieldGroup -> Field
* HttpFoundation\HeaderBag -> headers
* HttpFoundation\ParameterBag -> parameters
* HttpFoundation\Session -> attributes
* HttpKernel\Profiler\Profiler -> DataCollectorInterface
* Routing\RouteCollection -> Route
* Security\Authentication\AuthenticationProviderManager -> AuthenticationProviderInterface
* Templating\Engine -> HelperInterface
* Translation\MessageCatalogue -> messages
The usage of these methods are only allowed when it is clear that there is a
main relation:
* a CookieJar has many Cookies;
* a Container has many services and many parameters (as services is the main
relation, we use the naming convention for this relation);
* a Console Input has many arguments and many options. There is no "main"
relation, and so the naming convention does not apply.
For many relations where the convention does not apply, the following methods
must be used instead (where XXX is the name of the related thing):
* get() -> getXXX()
* set() -> setXXX()
* all() -> getXXXs()
* replace() -> setXXXs()
* remove() -> removeXXX()
* clear() -> clearXXX()
* isEmpty() -> isEmptyXXX()
* add() -> addXXX()
* register() -> registerXXX()
* count() -> countXXX()
* keys()
* removed the __call() method in Container: it means that now, there is only
one way to get a service: via the get() method;
* removed the $shared variable in the dumped Container classes (we now use
the $services variable from the parent class directly -- this is where we
have a performance improvement);
* optimized the PHP Dumper output.
This is the case for instance when you pass a variable to a template like this:
new SafeDecorator($var);
and in the template, you pass it again to another embedded template:
$view->render('...', array('var' => $var);
The second time, $var will be escaped as the SafeDecorator wrapper will have been removed
by the escaper.
The PHP native cache limiter feature has been disabled as this is now managed
by the HeaderBag class directly instead (see below.)
The HeaderBag class uses the following rules to define a sensible and
convervative default value for the Response 'Cache-Control' header:
* If no cache header is defined ('Cache-Control', 'ETag', 'Last-Modified',
and 'Expires'), 'Cache-Control' is set to 'no-cache';
* If 'Cache-Control' is empty, its value is set to "private, max-age=0,
must-revalidate";
* But if at least one 'Cache-Control' directive is set, and no 'public' or
'private' directives have been explicitely added, Symfony2 adds the
'private' directive automatically (except when 's-maxage' is set.)
So, remember to explicitly add the 'public' directive to 'Cache-Control' when
you want shared caches to store your application resources:
// The Response is private by default
$response->setEtag($etag);
$response->setLastModified($date);
$response->setMaxAge(10);
// Change the Response to be public
$response->setPublic();
// Set cache settings in one call
$response->setCache(array(
'etag' => $etag,
'last_modified' => $date,
'max_age' => 10,
'public' => true,
));
The constraint "Valid" does not accept any options or groups anymore. As per
JSR303 1.0 final, section 3.5.1 "Object graph validation" (page 39),
properties annotated with valid should be cascaded independent of the current
group (i.e. always). Thus the group "*" is not necessary anymore and was
removed from the "Valid" constraint in the Form validation.xml.
Support for theming in PHP templates has been dropped.
True theming should support theme inheritance, e.g. mytheme <- table <- default.
Currently, the Templating component does not support such inheritance. As the
only purpose of the themes so far was to style field groups with tables or
divs, and because automatic rendering of field groups/forms through the render()
method is discouraged and only recommended for rapid prototyping, themes are
dropped for now.
Modified the framework bundle to use validation => Symfony\Component\Validator\Validator defaults.
Enhanced Framework Extension validator configuration to allow to extend this configuration with
user-specified annotations, for example:
validation:
enabled: true
annotations:
namespaces:
myprojectvalidator: MyProject\Validator\
to register @myprojectvalidator:Validator(...)
This allows the translations to be deeply nested arrays that will be flattened, allowing for namespacing of translations easily.
The following:
'key' => array('key2' => array('key3' => 'value'))
Becomes:
'key.key2.key3' => 'value'
This isn't applied to Xliff since it does not make sense within the scope of the XLIFF standard
The idea of a string port is probably semantically wrong, but it actually follows the convention of at least some web servers ($_SERVER['SERVER_PORT'] is actually a string). And since the $port variable is used as a string in getHttpHost(), it's correct to allow the types not to match.
Added ability to specify **match-all** validation group, which
constraints will runs on every specified validation group.
Added groups="*" option to `Form::data` Valid validator.
In the dumped PHP class, we must use get() and not get*Service() methods to get services.
That's because all calls must be managed by get(). From the outside, you can call
get*Service() because as they are protected, they are caught by the __call() method;
which is not the case obviously when it is used internally.
If not, if you override a service with set(), this won't work when a service
depends on this one (the default one will still be used).
Some explanations on how it works now:
* The Session is an optional dependency of the Request. If you create the
Request yourself (which is mandatory now in the front controller) and if
you don't inject a Session yourself (which is recommended if you want the
session to be configured via dependency injection), the Symfony2 Kernel
will associate the Session configured in the Container with the Request
automatically.
* When duplicating a request, the session is shared between the parent and
the child (that's because duplicated requests are sub-requests of the main
one most of the time.) Notice that when you use ::create(), the behavior is
the same as for the constructor; no session is attached to the Request.
* Symfony2 tries hard to not create a session cookie when it is not needed
but a Session object is always available (the cookie is only created when
"something" is stored in the session.)
* Symfony2 only starts a session when:
* A session already exists in the request ($_COOKIE[session_name()] is
defined -- this is done by RequestListener);
* There is something written in the session object (the cookie will be sent
to the Client).
* Notice that reading from the session does not start the session anymore (as
we don't need to start a new session to get the default values, and because
if a session exists, it has already been started by RequestListener.)
Because that's just not possible (have a look at the unit tests to see all possibilities
-- as you will notice, there is no way we can determine the context and whether the
data are already escaped or not).
So, we always escape data, which means that sometimes, we will try to escape already
escaped data. This is not a problem for everything except strings. That's because
strings are not wrapped with an object like everything else (for performance reason).
This means that all escapers must be able to avoid double-escaping (that's the case
for the default escapers as both htmlspecialchars() and htmlentities() have a flag
that does just this).
This is not really a bug or a big issue, but if you need to temporarily empty a routes node, Symfony shouldn't care - it's not an actual validation failure (a routes node still makes sense without an route or import children).
Fields can now easier support different data types in their underlying object.
These datatypes can be normalized to a single datatype using a normalization
transformer. The normalized value can then be transformed to the user's
representation with the value transformer (better name required?).
This fixes a bug in UniversalClassLoader when attempting to autoload class names with leading slashes:
$namespacedClass = "\\Foo\\Bar";
$pearlikeClass = "\\Foo_Bar";
$namespaced = new $namespacedClass();
$pearlike = new $pearlikeClass();
`UniversalClassLoader::loadClass()` was unable to load PEAR-like classes with leading slashes because it found the slash and assumed that the requested class was namespaced. It was unable to load namespaced classes with leading slashes because it would look them up in the autoloader's registered namespaces, and was unable to match '\Foo' to 'Foo'. One (ugly) workaround for the namespaced classes was to register all namespaces twice:
$loader->registerNamespaces(array(
'Foo' => __DIR__ . '/lib',
'\Foo' => __DIR__ . '/lib',
));
But that's not very pretty, nor does it solve the bug with PEAR-like classes. Stripping the leading slash before trying to autoload allows UniversalClassLoader to load both namespaced and PEAR-like classes.
When reading the last bit of a property path mapped to a missing array index, the method would initialize the value to an empty array. This makes sense for cases where readPropertyPath would again be called recursively, but not when the value would be immediately returned (null would be preferable in that case).
For example, we have an object with a property called "options" that's an array of arbitrary key/value pairs. That "options" property (and getOptions()) maps directly to a FieldGroup within the Form for this object. That FieldGroup contains multiple TextFields for a few expected keys in the array. As-is, if those keys were not defined, the default data set for those TextFields could end up being "Array" (string representation of an empty array). If readPropertyPath instead returns null for this case, the default data would be transformed into an empty string.
It's better to be able to fetch all the visible and all the hidden fields separately for display purposes (hidden fields in <ul> tags without an <li> do not validate)
Before:
/**
* @Validation({@DateTime()})
*/
After:
/**
* @validation:DateTime()
*/
The @validation:Validation() construct is not needed anymore (it is still supported
as this is useful when you have several annotations with the same class).
So, the above is equivalent to:
/**
* @validation:Validation({@validation:DateTime()})
*/
ReflectionClass doesn't list properties on stdClass objects (or objects cast
from arrays). This allows these annoymous objects to be used as field data.
Internally, ChoiceField expects both choices and preferred_choices to be a simple array, so I replaced incomplete bits of code that attempted to not modify a possible ArrayObject and instead added type checks in the configure() method (with unit tests for expected exceptions).
Property paths such as fields[group].fields[innerGroup].data were not being resolved correctly, since the second iteration of addError() (based on "group") would attempt to call get('fields') instead of get('innerGroup'). Solution is to remember to bump the propertyPath forward if we're at the fields property
<foo:bar>
<service class="Foo" />
<service class="Bar" />
</foo:bar>
In the foo:bar extension method, you can retrieve the services with:
// always an array of services
$config['_services']