Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 572 lines (423 sloc) 17.33 kB
6b601bd @jfsimon [http-foudation] Better accept header parsing
jfsimon authored
1 UPGRADE FROM 2.1 to 2.2
2 =======================
3
64d43c8 @fabpot restricted to only URIs the first argument of the render tag
fabpot authored
4 ### TwigBridge
5
6 * The `render` tag signature and arguments changed.
7
8 Before:
9
10 ```
11 {% render 'BlogBundle:Post:list' with { 'limit': 2 }, { 'alt': 'BlogBundle:Post:error' } %}
12 ```
13
14 After:
15
16 ```
76fefe3 @fabpot updated CHANGELOG and UPGRADE files
fabpot authored
17 {% render controller('BlogBundle:Post:list', { 'limit': 2 }), { 'alt': 'BlogBundle:Post:error' } %}
64d43c8 @fabpot restricted to only URIs the first argument of the render tag
fabpot authored
18 ```
19
ded3a83 @jmikola [HttpFoundation] Document MongoDbSessionHandler changes
jmikola authored
20 ### HttpFoundation
21
22 * The MongoDbSessionHandler default field names and timestamp type have changed.
23
24 The `sess_` prefix was removed from default field names. The session ID is
25 now stored in the `_id` field by default. The session date is now stored as a
26 `MongoDate` instead of `MongoTimestamp`, which also makes it possible to use
27 TTL collections in MongoDB 2.2+ instead of relying on the `gc()` method.
28
bdf0334 @dlsniper Fixed the lap method. Added upgrade notes. Some CS fixes
dlsniper authored
29 * The Stopwatch functionality was moved from HttpKernel\Debug to its own component
30
0a380cf @fabpot [HttpFoundation] disabled Request _method feature by default (should …
fabpot authored
31 * The _method request parameter support has been disabled by default (call
32 Request::enableHttpMethodParameterOverride() to enable it).
33
6b601bd @jfsimon [http-foudation] Better accept header parsing
jfsimon authored
34 #### Deprecations
35
36 * The `Request::splitHttpAcceptHeader()` is deprecated and will be removed in 2.3.
37
38 You should now use the `AcceptHeader` class which give you fluent methods to
39 parse request accept-* headers. Some examples:
40
41 ```
42 $accept = AcceptHeader::fromString($request->headers->get('Accept'));
43 if ($accept->has('text/html') {
44 $item = $accept->get('html');
45 $charset = $item->getAttribute('charset', 'utf-8');
46 $quality = $item->getQuality();
47 }
48
49 // accepts items are sorted by descending quality
50 $accepts = AcceptHeader::fromString($request->headers->get('Accept'))->all();
51
52 ```
97f6a1b @egeloen [Form] Update password type trimming to false
egeloen authored
53
54 ### Form
55
fb71964 @webmozart [Form] Added an alternative signature Form::add($name, $type, $options)
webmozart authored
56 * The PasswordType is now not trimmed by default.
57
bcc5552 @webmozart [Form] Protected methods in FormConfigBuilder and FormBuilder from be…
webmozart authored
58 * The class FormException is now an interface. The old class is still available
59 under the name Symfony\Component\Form\Exception\Exception, but will probably
60 be removed before 2.2. If you created FormException instances manually,
61 you are now advised to create any of the other exceptions in the
62 Symfony\Component\Form\Exception namespace or to create custom exception
63 classes for your purpose.
64
1e34e91 @webmozart [Form] Added upgrade instructions to the UPGRADE file
webmozart authored
65 * Translating validation errors is now optional. You can still do so
66 manually if you like, or you can simplify your templates to simply output
67 the already translated message.
68
69 Before:
70
71 ```
72 {{
73 error.messagePluralization is null
74 ? error.messageTemplate|trans(error.messageParameters, 'validators')
75 : error.messageTemplate|transchoice(error.messagePluralization, error.messageParameters, 'validators')
76 }}
77 ```
78
79 After:
80
81 ```
82 {{ error.message }}
83 ```
84
1bae7b2 @webmozart [PropertyAccess] Extracted PropertyAccess component out of Form
webmozart authored
85 * FormType, ModelType and PropertyPathMapper now have constructors. If you
86 extended these classes, you should call the parent constructor now.
87 Note that you are not recommended to extend FormType nor ModelType. You should
88 extend AbstractType instead and use the Form component's own inheritance
89 mechanism (`AbstractType::getParent()`).
90
91 Before:
92
93 ```
94 use Symfony\Component\Form\Extensions\Core\DataMapper\PropertyPathMapper;
95
96 class CustomMapper extends PropertyPathMapper
97 {
98 public function __construct()
99 {
100 // ...
101 }
102
103 // ...
104 }
105 ```
106
107 After:
108
109 ```
110 use Symfony\Component\Form\Extensions\Core\DataMapper\PropertyPathMapper;
111
112 class CustomMapper extends PropertyPathMapper
113 {
114 public function __construct()
115 {
116 parent::__construct();
117
118 // ...
119 }
120
121 // ...
122 }
123 ```
124
fb71964 @webmozart [Form] Added an alternative signature Form::add($name, $type, $options)
webmozart authored
125 #### Deprecations
126
127 * The methods `getParent()`, `setParent()` and `hasParent()` in
128 `FormBuilderInterface` were deprecated and will be removed in Symfony 2.3.
129 You should not rely on these methods in your form type because the parent
130 of a form can change after building it.
24c6530 @webmozart [Validator] Added instructions on integrating the latest Validator ch…
webmozart authored
131
1bae7b2 @webmozart [PropertyAccess] Extracted PropertyAccess component out of Form
webmozart authored
132 * The class PropertyPath and related classes were deprecated and moved to a
133 dedicated component PropertyAccess. If you used any of these classes or
134 interfaces, you should adapt the namespaces now. During the move,
135 InvalidPropertyException was renamed to NoSuchPropertyException.
136
137 Before:
138
139 ```
140 use Symfony\Component\Form\Util\PropertyPath;
141 use Symfony\Component\Form\Util\PropertyPathBuilder;
142 use Symfony\Component\Form\Util\PropertyPathInterface;
143 use Symfony\Component\Form\Util\PropertyPathIterator;
144 use Symfony\Component\Form\Util\PropertyPathIteratorInterface;
145 use Symfony\Component\Form\Exception\InvalidPropertyException;
146 use Symfony\Component\Form\Exception\InvalidPropertyPathException;
147 use Symfony\Component\Form\Exception\PropertyAccessDeniedException;
148 ```
149
150 After:
151
152 ```
153 use Symfony\Component\PropertyAccess\PropertyPath;
154 use Symfony\Component\PropertyAccess\PropertyPathBuilder;
155 use Symfony\Component\PropertyAccess\PropertyPathInterface;
156 use Symfony\Component\PropertyAccess\PropertyPathIterator;
157 use Symfony\Component\PropertyAccess\PropertyPathIteratorInterface;
158 use Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException;
159 use Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException;
160 use Symfony\Component\PropertyAccess\Exception\PropertyAccessDeniedException;
161 ```
162
163 Also, `FormUtil::singularify()` was split away into a class StringUtil
164 in the new component.
165
166 Before:
167
168 ```
169 use Symfony\Component\Form\Util\FormUtil;
170
171 $singular = FormUtil::singularify($plural);
172 ```
173
174 After:
175
176 ```
177 use Symfony\Component\PropertyAccess\StringUtil;
178
179 $singular = StringUtil::singularify($plural);
180 ```
181
182 The methods `getValue()` and `setValue()` were moved to a new class
183 PropertyAccessor.
184
185 Before:
186
187 ```
188 use Symfony\Component\Form\Util\PropertyPath;
189
190 $propertyPath = new PropertyPath('some.path');
191
192 $value = $propertyPath->getValue($object);
193 $propertyPath->setValue($object, 'new value');
194 ```
195
196 After (alternative 1):
197
198 ```
199 use Symfony\Component\PropertyAccess\PropertyAccess;
200
201 $accessor = PropertyAccess::getPropertyAccessor();
202
203 $value = $propertyAccessor->getValue($object, 'some.path');
204 $accessor->setValue($object, 'some.path', 'new value');
205 ```
206
207 After (alternative 2):
208
209 ```
210 use Symfony\Component\PropertyAccess\PropertyAccess;
211 use Symfony\Component\PropertyAccess\PropertyPath;
212
213 $accessor = PropertyAccess::getPropertyAccessor();
214 $propertyPath = new PropertyPath('some.path');
215
216 $value = $propertyAccessor->getValue($object, $propertyPath);
217 $accessor->setValue($object, $propertyPath, 'new value');
218 ```
219
51223c0 @Tobion added upgrade instructions
Tobion authored
220 ### Routing
221
222 * RouteCollection does not behave like a tree structure anymore but as a flat
223 array of Routes. So when using PHP to build the RouteCollection, you must
224 make sure to add routes to the sub-collection before adding it to the parent
225 collection (this is not relevant when using YAML or XML for Route definitions).
226
227 Before:
228
229 ```
230 $rootCollection = new RouteCollection();
231 $subCollection = new RouteCollection();
232 $rootCollection->addCollection($subCollection);
233 $subCollection->add('foo', new Route('/foo'));
234 ```
235
236 After:
237
238 ```
239 $rootCollection = new RouteCollection();
240 $subCollection = new RouteCollection();
241 $subCollection->add('foo', new Route('/foo'));
242 $rootCollection->addCollection($subCollection);
243 ```
244
245 Also one must call `addCollection` from the bottom to the top hierarchy.
246 So the correct sequence is the following (and not the reverse):
247
248 ```
c9e8ee1 @kriswallsmith fixed typo
kriswallsmith authored
249 $childCollection->addCollection($grandchildCollection);
51223c0 @Tobion added upgrade instructions
Tobion authored
250 $rootCollection->addCollection($childCollection);
251 ```
252
253 * The methods `RouteCollection::getParent()` and `RouteCollection::getRoot()`
254 have been deprecated and will be removed in Symfony 2.3.
8c7a169 @Tobion [Routing] clean up of RouteCollection API
Tobion authored
255 * Misusing the `RouteCollection::addPrefix` method to add defaults, requirements
256 or options without adding a prefix is not supported anymore. So if you called `addPrefix`
257 with an empty prefix or `/` only (both have no relevance), like
258 `addPrefix('', $defaultsArray, $requirementsArray, $optionsArray)`
259 you need to use the new dedicated methods `addDefaults($defaultsArray)`,
260 `addRequirements($requirementsArray)` or `addOptions($optionsArray)` instead.
261 * The `$options` parameter to `RouteCollection::addPrefix()` has been deprecated
262 because adding options has nothing to do with adding a path prefix. If you want to add options
263 to all child routes of a RouteCollection, you can use `addOptions()`.
264 * The method `RouteCollection::getPrefix()` has been deprecated
265 because it suggested that all routes in the collection would have this prefix, which is
266 not necessarily true. On top of that, since there is no tree structure anymore, this method
267 is also useless.
268 * `RouteCollection::addCollection(RouteCollection $collection)` should now only be
269 used with a single parameter. The other params `$prefix`, `$default`, `$requirements` and `$options`
270 will still work, but have been deprecated. The `addPrefix` method should be used for this
271 use-case instead.
272 Before: `$parentCollection->addCollection($collection, '/prefix', array(...), array(...))`
273 After:
274 ```
275 $collection->addPrefix('/prefix', array(...), array(...));
276 $parentCollection->addCollection($collection);
277 ```
51223c0 @Tobion added upgrade instructions
Tobion authored
278
24c6530 @webmozart [Validator] Added instructions on integrating the latest Validator ch…
webmozart authored
279 ### Validator
280
1db6f05 @ragtek Update UPGRADE-2.2.md
ragtek authored
281 * Interfaces were created for the classes `ConstraintViolation`,
24c6530 @webmozart [Validator] Added instructions on integrating the latest Validator ch…
webmozart authored
282 `ConstraintViolationList`, `GlobalExecutionContext` and `ExecutionContext`.
283 If you type hinted against any of these classes, you are recommended to
284 type hint against their interfaces now.
285
286 Before:
287
288 ```
289 use Symfony\Component\Validator\ExecutionContext;
290
291 public function validateCustomLogic(ExecutionContext $context)
292 ```
293
294 After:
295
296 ```
fae3e35 @fabpot fixed typo
fabpot authored
297 use Symfony\Component\Validator\ExecutionContextInterface;
24c6530 @webmozart [Validator] Added instructions on integrating the latest Validator ch…
webmozart authored
298
299 public function validateCustomLogic(ExecutionContextInterface $context)
300 ```
301
302 For all implementations of `ConstraintValidatorInterface`, this change is
303 mandatory for the `initialize` method:
304
305 Before:
306
307 ```
308 use Symfony\Component\Validator\ConstraintValidatorInterface;
309 use Symfony\Component\Validator\ExecutionContext;
310
311 class MyValidator implements ConstraintValidatorInterface
312 {
313 public function initialize(ExecutionContext $context)
314 {
315 // ...
316 }
317 }
318 ```
319
320 After:
321
322 ```
323 use Symfony\Component\Validator\ConstraintValidatorInterface;
324 use Symfony\Component\Validator\ExecutionContextInterface;
325
326 class MyValidator implements ConstraintValidatorInterface
327 {
328 public function initialize(ExecutionContextInterface $context)
329 {
330 // ...
331 }
332 }
333 ```
334
cc0df0a @webmozart [Validator] Changed validator to support pluralized messages by default
webmozart authored
335 * The sources of the pluralized messages in translation files have changed
336 from the singular to the pluralized version. If you created custom
337 translation files for validator errors, you should adapt them.
338
339 Before:
340
341 <trans-unit id="6">
342 <source>You must select at least {{ limit }} choices.</source>
343 <target>Sie müssen mindestens {{ limit }} Möglichkeit wählen.|Sie müssen mindestens {{ limit }} Möglichkeiten wählen.</target>
344 </trans-unit>
345
346 After:
347
348 <trans-unit id="6">
349 <source>You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices.</source>
350 <target>Sie müssen mindestens {{ limit }} Möglichkeit wählen.|Sie müssen mindestens {{ limit }} Möglichkeiten wählen.</target>
351 </trans-unit>
352
353 Check the file src/Symfony/Component/Validator/Resources/translations/validators.en.xlf
354 for the new message sources.
355
24c6530 @webmozart [Validator] Added instructions on integrating the latest Validator ch…
webmozart authored
356 #### Deprecations
357
358 * The interface `ClassMetadataFactoryInterface` was deprecated and will be
359 removed in Symfony 2.3. You should implement `MetadataFactoryInterface`
360 instead, which changes the name of the method `getClassMetadata` to
361 `getMetadataFor` and accepts arbitrary values (e.g. class names, objects,
362 numbers etc.). In your implementation, you should throw a
363 `NoSuchMetadataException` if you don't support metadata for the given value.
364
365 Before:
366
367 ```
368 use Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface;
369
370 class MyMetadataFactory implements ClassMetadataFactoryInterface
371 {
372 public function getClassMetadata($class)
373 {
374 // ...
375 }
376 }
377 ```
378
379 After:
380
381 ```
382 use Symfony\Component\Validator\MetadataFactoryInterface;
383 use Symfony\Component\Validator\Exception\NoSuchMetadataException;
384
385 class MyMetadataFactory implements MetadataFactoryInterface
386 {
387 public function getMetadataFor($value)
388 {
389 if (is_object($value)) {
390 $value = get_class($value);
391 }
392
393 if (!is_string($value) || (!class_exists($value) && !interface_exists($value))) {
394 throw new NoSuchMetadataException(...);
395 }
396
397 // ...
398 }
399 }
400 ```
401
402 The return value of `ValidatorInterface::getMetadataFactory()` was also
403 changed to return `MetadataFactoryInterface`. Make sure to replace calls to
404 `getClassMetadata` by `getMetadataFor` on the return value of this method.
405
406 Before:
407
408 ```
409 $metadataFactory = $validator->getMetadataFactory();
410 $metadata = $metadataFactory->getClassMetadata('Vendor\MyClass');
411 ```
412
413 After:
414
415 ```
416 $metadataFactory = $validator->getMetadataFactory();
417 $metadata = $metadataFactory->getMetadataFor('Vendor\MyClass');
418 ```
419
420 * The class `GraphWalker` and the accessor `ExecutionContext::getGraphWalker()`
421 were deprecated and will be removed in Symfony 2.3. You should use the
422 methods `ExecutionContextInterface::validate()` and
423 `ExecutionContextInterface::validateValue()` instead.
424
425 Before:
426
427 ```
428 use Symfony\Component\Validator\ExecutionContext;
429
430 public function validateCustomLogic(ExecutionContext $context)
431 {
432 if (/* ... */) {
433 $path = $context->getPropertyPath();
434 $group = $context->getGroup();
435
436 if (!empty($path)) {
437 $path .= '.';
438 }
439
440 $context->getGraphWalker()->walkReference($someObject, $group, $path . 'myProperty', false);
441 }
442 }
443 ```
444
445 After:
446
447 ```
448 use Symfony\Component\Validator\ExecutionContextInterface;
449
450 public function validateCustomLogic(ExecutionContextInterface $context)
451 {
452 if (/* ... */) {
453 $context->validate($someObject, 'myProperty');
454 }
455 }
456 ```
457
458 * The method `ExecutionContext::addViolationAtSubPath()` was deprecated and
459 will be removed in Symfony 2.3. You should use `addViolationAt()` instead.
460
461 Before:
462
463 ```
464 use Symfony\Component\Validator\ExecutionContext;
465
466 public function validateCustomLogic(ExecutionContext $context)
467 {
468 if (/* ... */) {
469 $context->addViolationAtSubPath('myProperty', 'This value is invalid');
470 }
471 }
472 ```
473
474 After:
475
476 ```
477 use Symfony\Component\Validator\ExecutionContextInterface;
478
479 public function validateCustomLogic(ExecutionContextInterface $context)
480 {
481 if (/* ... */) {
482 $context->addViolationAt('myProperty', 'This value is invalid');
483 }
484 }
485 ```
486
487 * The methods `ExecutionContext::getCurrentClass()`, `ExecutionContext::getCurrentProperty()`
488 and `ExecutionContext::getCurrentValue()` were deprecated and will be removed
489 in Symfony 2.3. Use the methods `getClassName()`, `getPropertyName()` and
490 `getValue()` instead.
491
492 Before:
493
494 ```
495 use Symfony\Component\Validator\ExecutionContext;
496
497 public function validateCustomLogic(ExecutionContext $context)
498 {
499 $class = $context->getCurrentClass();
500 $property = $context->getCurrentProperty();
501 $value = $context->getCurrentValue();
502
503 // ...
504 }
505 ```
506
507 After:
508
509 ```
510 use Symfony\Component\Validator\ExecutionContextInterface;
511
512 public function validateCustomLogic(ExecutionContextInterface $context)
513 {
514 $class = $context->getClassName();
515 $property = $context->getPropertyName();
516 $value = $context->getValue();
517
518 // ...
519 }
520 ```
9071676 @ricardclau create oneof constraint and add deprecation messages in choice, also …
ricardclau authored
521
4d40b11 @benja-M-1 Add notes about kernel.trusted_proxies parameter
benja-M-1 authored
522 ### FrameworkBundle
523
3341c8e @fabpot [FrameworkBundle] restricted to only URIs the first argument of the a…
fabpot authored
524 * The `render` method of the `actions` templating helper signature and arguments changed:
525
526 Before:
527
528 ```
529 <?php echo $view['actions']->render('BlogBundle:Post:list', array('limit' => 2), array('alt' => 'BlogBundle:Post:error')) ?>
530 ```
531
532 After:
533
534 ```
535 <?php echo $view['actions']->render($view['router']->generate('post_list', array('limit' => 2)), array('alt' => 'BlogBundle:Post:error')) ?>
536 ```
537
76fefe3 @fabpot updated CHANGELOG and UPGRADE files
fabpot authored
538 where `post_list` is the route name for the `BlogBundle:Post:list`
539 controller, or if you don't want to create a route:
540
541 ```
542 <?php echo $view['actions']->render(new ControllerReference('BlogBundle:Post:list', array('limit' => 2)), array('alt' => 'BlogBundle:Post:error')) ?>
543 ```
3341c8e @fabpot [FrameworkBundle] restricted to only URIs the first argument of the a…
fabpot authored
544
4d40b11 @benja-M-1 Add notes about kernel.trusted_proxies parameter
benja-M-1 authored
545 #### Configuration
546
b7e4cff @fabpot tweaked previous merge
fabpot authored
547 * The 2.2 version introduces a new parameter `trusted_proxies` that replaces
548 `trust_proxy_headers` in the framework configuration.
4d40b11 @benja-M-1 Add notes about kernel.trusted_proxies parameter
benja-M-1 authored
549
550 Before:
551
552 ```
553 # app/config/config.yml
554 framework:
555 trust_proxy_headers: false
556 ```
557
558 After:
559
560 ```
561 # app/config/config.yml
562 framework:
b7e4cff @fabpot tweaked previous merge
fabpot authored
563 trusted_proxies: ['127.0.0.1', '10.0.0.1'] # a list of proxy IPs you trust
4d40b11 @benja-M-1 Add notes about kernel.trusted_proxies parameter
benja-M-1 authored
564 ```
b6bdb45 @beberlei Completly refactor the Serializer Options Pull Request to push contex…
beberlei authored
565
6923a48 @fabpot fixed markup
fabpot authored
566 ### Serializer
b6bdb45 @beberlei Completly refactor the Serializer Options Pull Request to push contex…
beberlei authored
567
6923a48 @fabpot fixed markup
fabpot authored
568 * All serializer interfaces (Serializer, Normalizer, Encoder) have been
569 extended with an optional `$context` array. This was necessary to allow for
570 more complex use-cases that require context information during the
571 (de)normalization and en-/decoding steps.
Something went wrong with that request. Please try again.