Commit Graph

295 Commits

Author SHA1 Message Date
Francis Besset
d3f5f3a44f Added comment 2012-12-14 12:28:48 +01:00
Francis Besset
773d818d6b [FrameworkBundle] Added a check on file mime type for CodeHelper::fileExcerpt() 2012-12-14 11:53:52 +01:00
Tobias Schultze
f0415ed3d1 [Routing] made reference type fully BC and improved phpdoc considerably 2012-12-13 20:13:11 +01:00
Tobias Schultze
75f59ebe01 [Routing] add support for path-relative and scheme-relative URL generation 2012-12-13 20:13:09 +01:00
Fabien Potencier
a7cd5f54ef fixed CS 2012-12-11 11:27:06 +01:00
Fabien Potencier
3d99374014 removed unused use statements 2012-11-04 09:29:19 +01:00
Bernhard Schussek
fb002d89ea [Form] Fixed variable passing from outer to inner blocks of the same FormView instance 2012-07-25 13:20:23 +02:00
Bernhard Schussek
dc3a680cd3 [Form] Improved FormRenderer API to reduce the size of the function call stack during rendering 2012-07-22 09:29:35 +02:00
Bernhard Schussek
921681658c [Form] Turned Twig filters into tests 2012-07-21 17:26:50 +02:00
Bernhard Schussek
8b72766473 [Form] Tweaked the generation of option tags for performance (PHP +200ms, Twig +50ms) 2012-07-21 12:56:50 +02:00
Bernhard Schussek
d072f35ea0 [Form] The properties of FormView are now accessed directly in order to increase performance (PHP +200ms, Twig +150ms) 2012-07-21 12:56:11 +02:00
Bernhard Schussek
629093ed25 [Form] Extracted common parts of FormHelper and FormExtension into separate classes 2012-07-16 21:39:27 +02:00
Bernhard Schussek
216c539e41 [Form] Implemented a more intelligent caching strategy in FormHelper (PHP +100ms, Twig +100ms) 2012-07-16 18:04:36 +02:00
Bernhard Schussek
69e5e58629 [Form] Individual rows of CollectionType cannot be styled anymore for performance reasons 2012-07-14 12:10:29 +02:00
Zach Badgett
2fa98e8a23 [FrameworkBundle] Changed DelegatingEngine::renderResponse to use specified engine's renderResponse 2012-07-09 22:41:10 -06:00
Fabien Potencier
d100ffaf76 fixed CS 2012-07-09 14:54:20 +02:00
Fabien Potencier
03d22b74ec fixed CS (mainly method signatures) 2012-07-09 14:43:50 +02:00
Victor Berchet
aef7663676 [FrameworkBundle] Create a dedicated template filename parser 2012-07-03 14:58:30 +02:00
Kris Wallsmith
c1e4166ead moved create of default form label to view layer 2012-06-24 07:57:42 -07:00
Bernhard Schussek
90516223ab Fixing email 2012-05-26 09:48:33 +02:00
Bernhard Schussek
98a7c0cf5f [Form] Consolidated FormInterface, FormBuilderInterface and FormViewInterface 2012-05-25 12:34:16 +02:00
Fabien Potencier
335d4eab86 fixed CS 2012-05-21 22:27:15 +02:00
Fabien Potencier
c01fed0c89 fixed CS 2012-05-21 22:25:19 +02:00
Fabien Potencier
3bdf52a16a fixed CS 2012-05-18 19:42:42 +02:00
Fabien Potencier
e173d79e34 fixed CS 2012-05-18 19:37:58 +02:00
Fabien Potencier
41621e42e9 fixed phpdoc @param alignment 2012-05-15 22:19:31 +02:00
Fabien Potencier
ce9791246b fixed phpdoc @param alignment 2012-05-15 18:56:32 +02:00
Bernhard Schussek
fcb2227ac9 [Form] Deprecated FieldType, which has been merged into FormType 2012-04-17 16:44:39 +02:00
Drak
910b5c7f83 [HttpFoudation] CS, more tests and some optimization. 2012-03-15 12:15:54 +05:45
Fabien Potencier
8a01dd5cff renamed getFlashes() to getFlashBag() to avoid clashes 2012-02-11 13:18:56 +01:00
Fabien Potencier
146a502a0e [FrameworkBundle] added some service aliases to avoid some BC breaks 2012-02-11 12:36:09 +01:00
Fabien Potencier
04942502a5 removed unused use statements 2012-02-11 11:53:03 +01:00
Fabien Potencier
7878a0a11a [HttpFoundation] renamed pop() to all() and getAll() to all() 2012-02-11 11:53:00 +01:00
Drak
dad60efccc [HttpFoundation] Add back get defaults and small clean-up.
Changed read-only method names from get*() to peek*()

Typo
2012-02-11 11:24:39 +05:45
Drak
27530cbb1e [HttpFoundation] Moved session related classes to own sub-namespace. 2012-02-11 11:24:31 +05:45
Drak
468391525a [HttpFoundation] Free bags from session storage and move classes to their own namespaces. 2012-02-11 11:24:26 +05:45
Drak
398acc9e9f [HttpFoundation] Reworked flashes to maintain same behaviour as in Symfony 2.0 2012-02-11 11:24:15 +05:45
Drak
7aaf024b2a [FrameworkBundle] Refactored code for changes to HttpFoundation component.
Native PHP sessions stored to file are done with session.storage.native_file
Functional testing is done with session.storage.mock_file

Default flash message implementation done with FlashBag (session.flash_bag)
Default attribute storage implementation with AttributeBag (session.attribute_bag)

Services added: session.storage.native_file, session.storage.native_memcache, session.storage.native_memcache,
session.storage.native_sqlite, session.storage.memcache, session.storage.memcached, session.storage.null,
session.storage.mock_file, session.flash_bag, session.attribute_bag

Services removed: session.storage.native, session.storage.filesystem
2012-02-11 11:21:26 +05:45
Fabien Potencier
5e0823c99c merged branch bschussek/issue1919 (PR #3156)
Commits
-------

8dc78bd [Form] Fixed YODA issues
600cec7 [Form] Added missing entries to CHANGELOG and UPGRADE
b154f7c [Form] Fixed docblock and unneeded use statement
399af27 [Form] Implemented checks to assert that values and indices generated in choice lists match their requirements
5f6f75c [Form] Fixed outstanding issues mentioned in the PR
7c70976 [Form] Fixed text in UPGRADE file
c26b47a [Form] Made query parameter name generated by ORMQueryBuilderLoader unique
18f92cd [Form] Fixed double choice fixing
f533ef0 [Form] Added ChoiceView class for passing choice-related data to the view
d72900e [Form] Incorporated changes suggested in PR comments
28d2f6d Removed duplicated lines from UPGRADE file
e1fc5a5 [Form] Restricted form names to specific characters to (1) fix generation of HTML IDs and to (2) avoid problems with property paths.
87b16e7 [Form] Greatly improved ChoiceListInterface and all of its implementations

Discussion
----------

[Form] Improved ChoiceList implementation and made form naming more restrictive

Bug fix: yes
Feature addition: yes
Backwards compatibility break: **yes**
Symfony2 tests pass: yes
Fixes the following tickets: #2869, #3021, #1919, #3153
Todo: adapt documentation

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

The changes in this PR are primarily motivated by the fact that invalid form/field names lead to various problems.

1. When a name contains any characters that are not permitted in HTML "id" attributes, these are invalid
2. When a name contains periods ("."), form validation is broken, because they confuse the property path resolution
3. Since choices in expanded choice fields are directly translated to field names, choices applying to either 1. or 2. lead to problems. But choices should be unrestricted.
4. Unless a choice field is not expanded and does not allow multiple selection, it is not possible to use empty strings as choices, which might be desirable in some occasions.

The solution to these problems is to

* Restrict form names to disallow unpermitted characters (solves 1. and 2.)
* Generate integer indices to be stored in the HTML "id" and "name" attributes and map them to the choices (solves 3.). Can be reverted to the old behaviour by setting the option "index_generation" to ChoiceList::COPY_CHOICE
* Generate integer values to be stored in the HTML "value" attribute and map them to the choices (solves 4.). Can be reverted to the old behaviour by setting the option "value_generation" to ChoiceList::COPY_CHOICE

Apart from these fixes, it is now possible to write more flexible choice lists. One of these is `ObjectChoiceList`, which allows to use objects as choices and is bundled in the core. `EntityChoiceList` has been made an extension of this class.

    $form = $this->createFormBuilder()
        ->add('object', 'choice', array(
            'choice_list' => new ObjectChoiceList(
                array($obj1, $obj2, $obj3, $obj4),
                // property path determining the choice label (optional)
                'name',
                // preferred choices (optional)
                array($obj2, $obj3),
                // property path for object grouping (optional)
                'category',
                // property path for value generation (optional)
                'id',
                // property path for index generation (optional)
                'id'
            )
        ))
        ->getForm()
    ;

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

by kriswallsmith at 2012-01-19T18:09:09Z

Rather than passing `choices` and a `choice_labels` arrays to the view would it make sense to introduce a `ChoiceView` class and pass one array of objects?

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

by stof at 2012-01-22T15:32:36Z

@bschussek can you update your PR according to the feedback (and rebase it as it conflicts according to github) ?

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

by bschussek at 2012-01-24T00:15:42Z

@kriswallsmith fixed

Fixed all outstanding issues. Would be glad if someone could review again, otherwise this PR is ready to merge.

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

by fabpot at 2012-01-25T15:17:59Z

Is it ready to be merged?

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

by Tobion at 2012-01-25T15:35:50Z

Yes I think so. He said it's ready to be merged when reviewed.

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

by bschussek at 2012-01-26T02:30:36Z

Yes.

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

by bschussek at 2012-01-28T12:39:00Z

Fixed outstanding issues. Ready for merge.
2012-01-28 15:19:10 +01:00
Bernhard Schussek
f533ef0e1b [Form] Added ChoiceView class for passing choice-related data to the view 2012-01-24 01:07:33 +01:00
lsmith77
cc31a157d3 tweaked the exception message 2012-01-23 22:02:19 +01:00
lsmith77
3a1699a420 handle disaled csrf protection in the Twig FormExtension 2012-01-23 18:05:48 +01:00
lsmith77
2a998e01b9 handle disabled csrf protection in the PHP templating form helper 2012-01-23 17:49:28 +01:00
Fabien Potencier
35a61b3a52 [HttpKernel] added arguments to ExceptionHandler (closes #2739) 2012-01-22 16:53:27 +01:00
Kris Wallsmith
753c06761a [FrameworkBundle] added $view['form']->csrfToken() helper 2012-01-10 05:18:23 -08:00
Fabien Potencier
5d6a7d35b0 merged 2.0 2011-12-18 14:48:17 +01:00
Fabien Potencier
4316595dbb fixed CS 2011-12-18 14:42:59 +01:00
Fabien Potencier
a6cdddd716 merged 2.0 2011-12-14 19:13:35 +01:00
Fabien Potencier
12ea7568a0 merged branch pulzarraider/explode_optimalisation (PR #2782)
Commits
-------

cd24fb8 change explode's limit parameter based on known variable content
b3cc270 minor optimalisations for explode

Discussion
----------

[FrameworkBundle][CssSelector][HttpFoundation][HttpKernel] [Security][Validator] Minor optimizations for "explode" function

Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -

I added limit parameter in some places, where it may be usefull. I did not check the context of what values may have been exploded. So to not break anything, I added +1 to limit parameter.

If you find out that in some places limit (or limit+1) is not important or meaningless, write a comment please and I will fix it.

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

by fabpot at 2011/12/07 06:56:49 -0800

Adding +1 just to be sure to not break anything is clearly something we won't do. What is the benefit of doing that anyway?

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

by pulzarraider at 2011/12/07 13:50:24 -0800

The main idea of making this PR was to notify about some places that may run faster with just adding one parameter to explode function.

If in code is someting like: ```list($a, $b) = explode(':', $s);```
Function ```explode``` will create n-items (depends on ```$s```), but we need in code only the first two items. There is no reason to let ```explode``` create more items in memory that are NEVER used in our code. The limit parameter is there for these situations, so let's use it.

I know that it is microoptimization and may look unimportant, but we are writing a framework - so people expect that code will be as fast as possible without this kind of mistakes.

As I've noticed above, I know that +1 is not ideal solution, but the fastest without debugging the code. I expect that someone (with good knowledge of that code) will look at it and write in comments if variable may contain 1 comma (dot or someting on what is doing the explode) or maybe 2 in some situations or more.

Anyway, +1 will not break anything, because same items are created as it is now, but no unnecessary item is created.

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

by fabpot at 2011/12/07 23:14:59 -0800

I'm +1 for adding the number to avoid problems but I'm -1 on the optimization side of things as it won't optimize anything.

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

by helmer at 2011/12/08 12:46:49 -0800

*.. The main idea of making this PR was to notify about some places that **may** run faster ..*

I am also unsure the optimization is really an optimization, care to benchmark (with meaningful inputs)? As for the limit+1 thing, why would you want to +1 it? The number of ``list`` arguments should always reflect the ``limit`` parameter, no?

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

by pulzarraider at 2011/12/08 23:11:34 -0800

@helmer please try this simple benchmark:

```
<?php

header('Content-Type: text/plain; charset=UTF-8');
define('COUNT', 10000);

$source_string = 'aaaaaaaaaaaaaaaaaaaa:bbbbbbbbbbbbbbbbbbbbb:cccccccccccccccccccccccc:dddddddddddddddddddddd:eeeeeeeeeeeeeeeeeeeeeeeee:fffffffffffffffffffffffffff';

$start = microtime(true);
for ($i = 0; $i < COUNT; $i++) {
    list($a, $b) = explode(':', $source_string);
}
$end = microtime(true)-$start;
echo 'without limit: '.$end."\n";

$start = microtime(true);
for ($i = 0; $i < COUNT; $i++) {
    list($a, $b) = explode(':', $source_string, 2);
}
$end = microtime(true)-$start;
echo 'with limit:    '.$end."\n";
```

My results are:

```
without limit: 0.057228803634644
with limit:    0.028676986694336
```
That is 50% difference (with APC enabled).  Of course the result depends on the length of source string and if it's too short, the difference may be none or very very small. That's why I said, that it **may** run faster and is just a micro optimization.

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

by pulzarraider at 2011/12/08 23:18:12 -0800

@helmer And why +1? It depends on a code:

```
$source_string = 'aaaaaaaaaaaaaaaaaaaa:bbbbbbbbbbbbbbbbbbbbb:cccccccccccccccccccccccc';
list($a, $b) = explode(':', $source_string, 2);
var_dump($a, $b);
```

and

```
$source_string = 'aaaaaaaaaaaaaaaaaaaa:bbbbbbbbbbbbbbbbbbbbb:cccccccccccccccccccccccc';
list($a, $b) = explode(':', $source_string, 3);
var_dump($a, $b);
```
gives different results. That's why the content of the variable must be known.

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

by helmer at 2011/12/09 00:08:28 -0800

@pulzarraider Thanks for the benchmark, seems like a gain enough. Although, we are more likely having a scenario of:
``explode(':', 'a🅱️c')`` vs ``explode(':', 'a🅱️c', 3)`` with a ``COUNT`` of 10, where the difference is not even in microseconds anymore :)

The limit addition alters the behaviour though, ie suddenly you can define a controller [logical name](http://symfony.com/doc/current/book/routing.html#controller-string-syntax) as ´´AcmeBlogBundle:Blog:show:something``, and things go downhill from there on.

All that aside, I'm +1 for setting the limit to the exact number of ``list`` parameters, but certainly not number+1, this is just too wtfy (as you said, this was a safety thing, but I reckon for this PR to be merged it needs to be +0).

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

by drak at 2011/12/09 08:28:58 -0800

Overall `list()` is ugly as it's not very explicit.  Even though it would mean extra lines, it's better to `explode()` then explicitly assign variables:

```
$parts = explode(':', $foo);
$name = $parts[0];
$tel = $parts[1];
```

`list()` is one of those bad relics from the PHP past...

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

by fabpot at 2011/12/11 10:07:47 -0800

@drak: why is `list` not explicit? It is in fact as explicit as the more verbose syntax you propose.

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

by pulzarraider at 2011/12/11 13:08:50 -0800

@drak: I agree with @fabpot. In speech of benchmarks ```list``` is faster then using a helper variable.

@fabpot, @helmer I've changed explode's limit to be correct (without +1) and removed some changes from this PR, where I can't find out what the content of variable may be. Unit tests pass, so I think it's ready for merge.
2011-12-13 17:39:32 +01:00
Fabien Potencier
142cef21bb merged 2.0 2011-12-13 16:12:53 +01:00
Fabien Potencier
e3421a0b1d [DoctrineBridge] fixed some CS 2011-12-13 10:22:12 +01:00
Andrej Hudec
cd24fb86a8 change explode's limit parameter based on known variable content 2011-12-11 21:58:35 +01:00
Andrej Hudec
b3cc270450 minor optimalisations for explode 2011-12-11 21:58:30 +01:00
Victor Berchet
db2d773d93 [FrameworkBundle] Improve the TemplateLocator exception message 2011-12-09 10:35:15 +01:00
Fabien Potencier
4730f4303b merged 2.0 2011-12-08 15:36:57 +01:00
Alexander
6c69592ab2 [FrameworkBundle] Remove unused variable in TemplateLocator 2011-12-08 09:01:07 +01:00
Fabien Potencier
8a4f9ea512 merged 2.0 2011-12-01 15:45:30 +01:00
Hugo Hamon
5e5050db53 [FrameworkBundle] fixed unescaped file_link_format parameter in CodeHelper that made the functional tests fail when checking a 4xx page. The generated file link format used in an HTML stack trace didn't contain an escaped ampersand (&) character. The resulting HTML code was not validable against its DTD and so the Crawler made the tests fail when checking a 4xx page. 2011-12-01 10:53:50 +01:00
Francis Besset
17dc605ca0 [FrameworkBundle] Checks that the template is readable before checking its modification time 2011-11-26 13:28:35 +01:00
Fabien Potencier
5d91849999 merged 2.0 2011-11-07 20:53:25 +01:00
Fabien Potencier
b33198f842 fixed CodeHelper::formatFileFromText() method to allow &quot; as a file wrapper (it occurs for the main exception message) 2011-11-07 20:49:42 +01:00
Fabien Potencier
74bc699b27 moved management of the locale from the Session class to the Request class
The locale management does not require sessions anymore.

In the Symfony2 spirit, the locale should be part of your URLs. If this is the case
(via the special _locale request attribute), Symfony will store it in the request
(getLocale()).

This feature is now also configurable/replaceable at will as everything is now managed
by the new LocaleListener event listener.

How to upgrade:

The default locale configuration has been moved from session to the main configuration:

Before:

framework:
    session:
        default_locale: en

After:

framework:
    default_locale: en

Whenever you want to get the current locale, call getLocale() on the request (was on the
session before).
2011-10-08 18:34:49 +02:00
Fabien Potencier
902bbf2ba0 merged branch lsmith77/template_locator (PR #2128)
Commits
-------

afc0971 make it easier to customize the cache lookup in the TemplateLocator

Discussion
----------

make it easier to customize the cache lookup in the TemplateLocator

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

by fabpot at 2011/09/22 01:21:56 -0700

Do you any use case for that?

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

by lsmith77 at 2011/09/22 01:27:06 -0700

Yes in the ThemeBundle we override the default cache to include the key + theme:
https://github.com/liip/liipthemebundle/pull/9/files#L7R53

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

by lsmith77 at 2011/09/22 01:29:18 -0700

though i just thought about it .. if we do not put this into 2.0, it might not be worth the trouble.

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

by pjedrzejewski at 2011/09/22 02:19:42 -0700

+1 for this.
2011-09-23 21:00:46 +02:00
H. Westphal
3e2f1a4b13 Removed executable bits from all php files 2011-09-09 15:16:17 +02:00
H. Westphal
a0a97c6a22 Removed executable bits from all php files 2011-09-07 22:51:20 +02:00
Lukas Kahwe Smith
afc097118f make it easier to customize the cache lookup in the TemplateLocator 2011-09-07 20:02:35 +02:00
Fabien Potencier
0eae562cb2 converted file_exists calls to either is_file or is_dir where it makes sense 2011-08-29 15:28:26 +02:00
realmfoo
4f9d229e78 The trace argument value could be string ("*DEEP NESTED ARRAY*") 2011-08-10 12:08:47 +04:00
Fabien Potencier
04ac1fdba2 [Routing] changed UrlGeneratorInterface::generate() signature to allow passing objects instead of arrays 2011-07-26 08:00:41 +02:00
marc.weistroff
2b4cc9bd06 [Form] Changed collection prototype rendering.
Based on PR 1500. It is now rendered inside an attribute of collection
tag.
2011-07-22 11:01:55 +02:00
Geoffrey Tran
8e169e4457 Improved performance when assetic's use_controller is enabled
When assetic's use_controller is enabled, assetic has to loop through all the templates and create TemplateReferences through the assetic FileResource. This in turn causes a lot of calls to getLogicalName() leading to 5x the calls to the TemplateReference's get() (16k in my case). By accessing the protected field directly compared to using get() we achieve better performance during development (33% in my case).
2011-07-15 20:52:23 -05:00
Fabien Potencier
bd89cc7b37 [FrameworkBundle] fixed Template parser to accept template with dots 2011-07-04 22:38:34 +02:00
Victor Berchet
5d46e63089 [Form] Add the FormHelper configuration 2011-06-22 10:27:21 +02:00
Victor Berchet
1cb2129772 [FrameworkBundle][Form] Adding a cache to FormHelper::lookupTemplate() 2011-06-22 10:27:20 +02:00
Victor Berchet
f39ce6709d [Form][FrameworkBundle] PHP theming 2011-06-22 09:23:22 +02:00
Victor Berchet
2c1108ce6b [Form] Revert the ability to override anything else than the text of the label while rendering a row 2011-06-22 08:36:45 +02:00
Victor Berchet
da467a6b11 [Form] Fix the exception message when no block is found while rendering 2011-06-20 12:29:05 +02:00
Victor Berchet
41e07c96e3 [Form] Optimize rendering 2011-06-20 12:29:04 +02:00
Victor Berchet
f729c6ba93 [Form] Add the ability to override label & widget options when rendering a row 2011-06-20 12:29:04 +02:00
Victor Berchet
e09ae3f6a2 [Form][FrameworkBundle] Make FormHelper::renderSection() recursively callable, introduce FormHelper::renderBlock() 2011-06-20 12:29:04 +02:00
Hugo Hamon
7d09695903 [FrameworkBundle] Simplified TemplateReference::getPath() method and added a unit test. 2011-06-15 18:56:20 +02:00
Hugo Hamon
2616efb03f [FrameworkBundle] fixed TemplateRefence::getPath() when using namespaced controllers (i.e: AcmeBlogBundle\\Controller\\Admin\\PostController) 2011-06-15 18:27:34 +02:00
Fabien Potencier
01fcd7bdfd merged branch kaiwa/loglevel (PR #1073)
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.
2011-06-15 12:31:31 +02:00
Fabien Potencier
73dc8c96af merged branch vicb/form-proto (PR #1315)
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 !
2011-06-15 11:27:12 +02:00
Victor Berchet
b709551252 [Order] Make Form::types and FormView::types use the same order (Parent > Child) 2011-06-15 01:45:26 +02:00
Victor Berchet
c68c511388 [Form] Make theming form prototypes consistent (start by looking for a '_<id>_<section>' block) 2011-06-14 16:36:31 +02:00
Fabien Potencier
a232c148eb fixed CS 2011-06-14 12:54:32 +02:00
Fabien Potencier
566511e9e7 moved some FormView methods to FormUtil where they really belongs 2011-06-08 14:07:04 +02:00
Fabien Potencier
97a745e973 Merge remote branch 'vicb/form-rendering-fix'
* vicb/form-rendering-fix:
  [Form] Fix accessibility for file inputs
  [FrameworkBundle] Fix the FormHelper phpDoc
  [FrameworkBundle][Form] Add some phpDoc for the FormHelper class
  [FrameworkBundle][Form] Fix label rendering
  [FrameworkBundle][Form] Fix rendering search inputs in PHP
  [Form] FormType labels should never have a for attribute
  [Form] Never render a view again
2011-06-07 19:46:20 +02:00
Fabien Potencier
a17478ff74 tweaked previous commit 2011-06-07 11:48:08 +02:00
Fabien Potencier
96fc666454 simplified cache warmers
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.
2011-06-07 11:42:27 +02:00
Fabien Potencier
5be0bafe7f removed TemplateReferenceInterface::getSignature() (replaced by the existing getLogicalName() which already acts as a unique identifier) 2011-06-07 10:12:38 +02:00
Fabien Potencier
5af7c7fffd moved TemplateFinder to CacheWarmer as it is only useful in this context 2011-06-07 09:39:41 +02:00
Victor Berchet
c0355038cf [FrameworkBundle] Fix the FormHelper phpDoc 2011-06-06 21:00:07 +02:00
Victor Berchet
1196eb8e51 [FrameworkBundle][Form] Add some phpDoc for the FormHelper class 2011-06-06 20:12:37 +02:00
Victor Berchet
5044a7b56d [FrameworkBundle][Form] Fix label rendering
The label should not include the view 'id' attribute as it is used by the view widget.
2011-06-06 20:12:03 +02:00
Victor Berchet
b12b11c131 [Form] Never render a view again
If some of the nested views are rendered individually they should not be rendered again when calling form_rest.
A typical would be when some nested file views are rendered, form_rest should not render them again.

It is still possible to render a label once the widget has been rendered. This is for checkboxes and radios
where the widget is typically rendered before the label.
2011-06-06 18:01:03 +02:00
Fabien Potencier
cb1f2c7e69 Merge remote branch 'kriswallsmith/templating/packages-rework'
* kriswallsmith/templating/packages-rework:
  [FrameworkBundle] updated for templating changes, added http/ssl logic
  [Templating] reworked asset helper and packages
2011-06-04 18:25:52 +02:00
Fabien Potencier
2093a45aef merged stloyd/form_label 2011-06-01 11:11:25 +02:00
stloyd
cb22ccc516 [Form] Added missing feature for adding attributes to an field label 2011-05-31 17:01:28 +02:00