Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 434 lines (322 sloc) 13.306 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 ```
17 {% render url('post_list', { 'limit': 2 }), { 'alt': 'BlogBundle:Post:error' } %}
18 ```
19
20 where `post_list` is the route name for the `BlogBundle:Post:list` controller.
21
ded3a83 @jmikola [HttpFoundation] Document MongoDbSessionHandler changes
jmikola authored
22 ### HttpFoundation
23
24 * The MongoDbSessionHandler default field names and timestamp type have changed.
25
26 The `sess_` prefix was removed from default field names. The session ID is
27 now stored in the `_id` field by default. The session date is now stored as a
28 `MongoDate` instead of `MongoTimestamp`, which also makes it possible to use
29 TTL collections in MongoDB 2.2+ instead of relying on the `gc()` method.
30
bdf0334 @dlsniper Fixed the lap method. Added upgrade notes. Some CS fixes
dlsniper authored
31 * The Stopwatch functionality was moved from HttpKernel\Debug to its own component
32
0a380cf @fabpot [HttpFoundation] disabled Request _method feature by default (should now...
fabpot authored
33 * The _method request parameter support has been disabled by default (call
34 Request::enableHttpMethodParameterOverride() to enable it).
35
6b601bd @jfsimon [http-foudation] Better accept header parsing
jfsimon authored
36 #### Deprecations
37
38 * The `Request::splitHttpAcceptHeader()` is deprecated and will be removed in 2.3.
39
40 You should now use the `AcceptHeader` class which give you fluent methods to
41 parse request accept-* headers. Some examples:
42
43 ```
44 $accept = AcceptHeader::fromString($request->headers->get('Accept'));
45 if ($accept->has('text/html') {
46 $item = $accept->get('html');
47 $charset = $item->getAttribute('charset', 'utf-8');
48 $quality = $item->getQuality();
49 }
50
51 // accepts items are sorted by descending quality
52 $accepts = AcceptHeader::fromString($request->headers->get('Accept'))->all();
53
54 ```
97f6a1b @egeloen [Form] Update password type trimming to false
egeloen authored
55
56 ### Form
57
fb71964 @webmozart [Form] Added an alternative signature Form::add($name, $type, $options)
webmozart authored
58 * The PasswordType is now not trimmed by default.
59
bcc5552 @webmozart [Form] Protected methods in FormConfigBuilder and FormBuilder from being...
webmozart authored
60 * The class FormException is now an interface. The old class is still available
61 under the name Symfony\Component\Form\Exception\Exception, but will probably
62 be removed before 2.2. If you created FormException instances manually,
63 you are now advised to create any of the other exceptions in the
64 Symfony\Component\Form\Exception namespace or to create custom exception
65 classes for your purpose.
66
1e34e91 @webmozart [Form] Added upgrade instructions to the UPGRADE file
webmozart authored
67 * Translating validation errors is now optional. You can still do so
68 manually if you like, or you can simplify your templates to simply output
69 the already translated message.
70
71 Before:
72
73 ```
74 {{
75 error.messagePluralization is null
76 ? error.messageTemplate|trans(error.messageParameters, 'validators')
77 : error.messageTemplate|transchoice(error.messagePluralization, error.messageParameters, 'validators')
78 }}
79 ```
80
81 After:
82
83 ```
84 {{ error.message }}
85 ```
86
fb71964 @webmozart [Form] Added an alternative signature Form::add($name, $type, $options)
webmozart authored
87 #### Deprecations
88
89 * The methods `getParent()`, `setParent()` and `hasParent()` in
90 `FormBuilderInterface` were deprecated and will be removed in Symfony 2.3.
91 You should not rely on these methods in your form type because the parent
92 of a form can change after building it.
24c6530 @webmozart [Validator] Added instructions on integrating the latest Validator chang...
webmozart authored
93
51223c0 @Tobion added upgrade instructions
Tobion authored
94 ### Routing
95
96 * RouteCollection does not behave like a tree structure anymore but as a flat
97 array of Routes. So when using PHP to build the RouteCollection, you must
98 make sure to add routes to the sub-collection before adding it to the parent
99 collection (this is not relevant when using YAML or XML for Route definitions).
100
101 Before:
102
103 ```
104 $rootCollection = new RouteCollection();
105 $subCollection = new RouteCollection();
106 $rootCollection->addCollection($subCollection);
107 $subCollection->add('foo', new Route('/foo'));
108 ```
109
110 After:
111
112 ```
113 $rootCollection = new RouteCollection();
114 $subCollection = new RouteCollection();
115 $subCollection->add('foo', new Route('/foo'));
116 $rootCollection->addCollection($subCollection);
117 ```
118
119 Also one must call `addCollection` from the bottom to the top hierarchy.
120 So the correct sequence is the following (and not the reverse):
121
122 ```
123 $childCollection->->addCollection($grandchildCollection);
124 $rootCollection->addCollection($childCollection);
125 ```
126
127 * The methods `RouteCollection::getParent()` and `RouteCollection::getRoot()`
128 have been deprecated and will be removed in Symfony 2.3.
8c7a169 @Tobion [Routing] clean up of RouteCollection API
Tobion authored
129 * Misusing the `RouteCollection::addPrefix` method to add defaults, requirements
130 or options without adding a prefix is not supported anymore. So if you called `addPrefix`
131 with an empty prefix or `/` only (both have no relevance), like
132 `addPrefix('', $defaultsArray, $requirementsArray, $optionsArray)`
133 you need to use the new dedicated methods `addDefaults($defaultsArray)`,
134 `addRequirements($requirementsArray)` or `addOptions($optionsArray)` instead.
135 * The `$options` parameter to `RouteCollection::addPrefix()` has been deprecated
136 because adding options has nothing to do with adding a path prefix. If you want to add options
137 to all child routes of a RouteCollection, you can use `addOptions()`.
138 * The method `RouteCollection::getPrefix()` has been deprecated
139 because it suggested that all routes in the collection would have this prefix, which is
140 not necessarily true. On top of that, since there is no tree structure anymore, this method
141 is also useless.
142 * `RouteCollection::addCollection(RouteCollection $collection)` should now only be
143 used with a single parameter. The other params `$prefix`, `$default`, `$requirements` and `$options`
144 will still work, but have been deprecated. The `addPrefix` method should be used for this
145 use-case instead.
146 Before: `$parentCollection->addCollection($collection, '/prefix', array(...), array(...))`
147 After:
148 ```
149 $collection->addPrefix('/prefix', array(...), array(...));
150 $parentCollection->addCollection($collection);
151 ```
51223c0 @Tobion added upgrade instructions
Tobion authored
152
24c6530 @webmozart [Validator] Added instructions on integrating the latest Validator chang...
webmozart authored
153 ### Validator
154
1db6f05 @ragtek Update UPGRADE-2.2.md
ragtek authored
155 * Interfaces were created for the classes `ConstraintViolation`,
24c6530 @webmozart [Validator] Added instructions on integrating the latest Validator chang...
webmozart authored
156 `ConstraintViolationList`, `GlobalExecutionContext` and `ExecutionContext`.
157 If you type hinted against any of these classes, you are recommended to
158 type hint against their interfaces now.
159
160 Before:
161
162 ```
163 use Symfony\Component\Validator\ExecutionContext;
164
165 public function validateCustomLogic(ExecutionContext $context)
166 ```
167
168 After:
169
170 ```
fae3e35 @fabpot fixed typo
fabpot authored
171 use Symfony\Component\Validator\ExecutionContextInterface;
24c6530 @webmozart [Validator] Added instructions on integrating the latest Validator chang...
webmozart authored
172
173 public function validateCustomLogic(ExecutionContextInterface $context)
174 ```
175
176 For all implementations of `ConstraintValidatorInterface`, this change is
177 mandatory for the `initialize` method:
178
179 Before:
180
181 ```
182 use Symfony\Component\Validator\ConstraintValidatorInterface;
183 use Symfony\Component\Validator\ExecutionContext;
184
185 class MyValidator implements ConstraintValidatorInterface
186 {
187 public function initialize(ExecutionContext $context)
188 {
189 // ...
190 }
191 }
192 ```
193
194 After:
195
196 ```
197 use Symfony\Component\Validator\ConstraintValidatorInterface;
198 use Symfony\Component\Validator\ExecutionContextInterface;
199
200 class MyValidator implements ConstraintValidatorInterface
201 {
202 public function initialize(ExecutionContextInterface $context)
203 {
204 // ...
205 }
206 }
207 ```
208
cc0df0a @webmozart [Validator] Changed validator to support pluralized messages by default
webmozart authored
209 * The sources of the pluralized messages in translation files have changed
210 from the singular to the pluralized version. If you created custom
211 translation files for validator errors, you should adapt them.
212
213 Before:
214
215 <trans-unit id="6">
216 <source>You must select at least {{ limit }} choices.</source>
217 <target>Sie müssen mindestens {{ limit }} Möglichkeit wählen.|Sie müssen mindestens {{ limit }} Möglichkeiten wählen.</target>
218 </trans-unit>
219
220 After:
221
222 <trans-unit id="6">
223 <source>You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices.</source>
224 <target>Sie müssen mindestens {{ limit }} Möglichkeit wählen.|Sie müssen mindestens {{ limit }} Möglichkeiten wählen.</target>
225 </trans-unit>
226
227 Check the file src/Symfony/Component/Validator/Resources/translations/validators.en.xlf
228 for the new message sources.
229
24c6530 @webmozart [Validator] Added instructions on integrating the latest Validator chang...
webmozart authored
230 #### Deprecations
231
232 * The interface `ClassMetadataFactoryInterface` was deprecated and will be
233 removed in Symfony 2.3. You should implement `MetadataFactoryInterface`
234 instead, which changes the name of the method `getClassMetadata` to
235 `getMetadataFor` and accepts arbitrary values (e.g. class names, objects,
236 numbers etc.). In your implementation, you should throw a
237 `NoSuchMetadataException` if you don't support metadata for the given value.
238
239 Before:
240
241 ```
242 use Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface;
243
244 class MyMetadataFactory implements ClassMetadataFactoryInterface
245 {
246 public function getClassMetadata($class)
247 {
248 // ...
249 }
250 }
251 ```
252
253 After:
254
255 ```
256 use Symfony\Component\Validator\MetadataFactoryInterface;
257 use Symfony\Component\Validator\Exception\NoSuchMetadataException;
258
259 class MyMetadataFactory implements MetadataFactoryInterface
260 {
261 public function getMetadataFor($value)
262 {
263 if (is_object($value)) {
264 $value = get_class($value);
265 }
266
267 if (!is_string($value) || (!class_exists($value) && !interface_exists($value))) {
268 throw new NoSuchMetadataException(...);
269 }
270
271 // ...
272 }
273 }
274 ```
275
276 The return value of `ValidatorInterface::getMetadataFactory()` was also
277 changed to return `MetadataFactoryInterface`. Make sure to replace calls to
278 `getClassMetadata` by `getMetadataFor` on the return value of this method.
279
280 Before:
281
282 ```
283 $metadataFactory = $validator->getMetadataFactory();
284 $metadata = $metadataFactory->getClassMetadata('Vendor\MyClass');
285 ```
286
287 After:
288
289 ```
290 $metadataFactory = $validator->getMetadataFactory();
291 $metadata = $metadataFactory->getMetadataFor('Vendor\MyClass');
292 ```
293
294 * The class `GraphWalker` and the accessor `ExecutionContext::getGraphWalker()`
295 were deprecated and will be removed in Symfony 2.3. You should use the
296 methods `ExecutionContextInterface::validate()` and
297 `ExecutionContextInterface::validateValue()` instead.
298
299 Before:
300
301 ```
302 use Symfony\Component\Validator\ExecutionContext;
303
304 public function validateCustomLogic(ExecutionContext $context)
305 {
306 if (/* ... */) {
307 $path = $context->getPropertyPath();
308 $group = $context->getGroup();
309
310 if (!empty($path)) {
311 $path .= '.';
312 }
313
314 $context->getGraphWalker()->walkReference($someObject, $group, $path . 'myProperty', false);
315 }
316 }
317 ```
318
319 After:
320
321 ```
322 use Symfony\Component\Validator\ExecutionContextInterface;
323
324 public function validateCustomLogic(ExecutionContextInterface $context)
325 {
326 if (/* ... */) {
327 $context->validate($someObject, 'myProperty');
328 }
329 }
330 ```
331
332 * The method `ExecutionContext::addViolationAtSubPath()` was deprecated and
333 will be removed in Symfony 2.3. You should use `addViolationAt()` instead.
334
335 Before:
336
337 ```
338 use Symfony\Component\Validator\ExecutionContext;
339
340 public function validateCustomLogic(ExecutionContext $context)
341 {
342 if (/* ... */) {
343 $context->addViolationAtSubPath('myProperty', 'This value is invalid');
344 }
345 }
346 ```
347
348 After:
349
350 ```
351 use Symfony\Component\Validator\ExecutionContextInterface;
352
353 public function validateCustomLogic(ExecutionContextInterface $context)
354 {
355 if (/* ... */) {
356 $context->addViolationAt('myProperty', 'This value is invalid');
357 }
358 }
359 ```
360
361 * The methods `ExecutionContext::getCurrentClass()`, `ExecutionContext::getCurrentProperty()`
362 and `ExecutionContext::getCurrentValue()` were deprecated and will be removed
363 in Symfony 2.3. Use the methods `getClassName()`, `getPropertyName()` and
364 `getValue()` instead.
365
366 Before:
367
368 ```
369 use Symfony\Component\Validator\ExecutionContext;
370
371 public function validateCustomLogic(ExecutionContext $context)
372 {
373 $class = $context->getCurrentClass();
374 $property = $context->getCurrentProperty();
375 $value = $context->getCurrentValue();
376
377 // ...
378 }
379 ```
380
381 After:
382
383 ```
384 use Symfony\Component\Validator\ExecutionContextInterface;
385
386 public function validateCustomLogic(ExecutionContextInterface $context)
387 {
388 $class = $context->getClassName();
389 $property = $context->getPropertyName();
390 $value = $context->getValue();
391
392 // ...
393 }
394 ```
9071676 @ricardclau create oneof constraint and add deprecation messages in choice, also mak...
ricardclau authored
395
4d40b11 @benja-M-1 Add notes about kernel.trusted_proxies parameter
benja-M-1 authored
396 ### FrameworkBundle
397
3341c8e @fabpot [FrameworkBundle] restricted to only URIs the first argument of the acti...
fabpot authored
398 * The `render` method of the `actions` templating helper signature and arguments changed:
399
400 Before:
401
402 ```
403 <?php echo $view['actions']->render('BlogBundle:Post:list', array('limit' => 2), array('alt' => 'BlogBundle:Post:error')) ?>
404 ```
405
406 After:
407
408 ```
409 <?php echo $view['actions']->render($view['router']->generate('post_list', array('limit' => 2)), array('alt' => 'BlogBundle:Post:error')) ?>
410 ```
411
412 where `post_list` is the route name for the `BlogBundle:Post:list` controller.
413
4d40b11 @benja-M-1 Add notes about kernel.trusted_proxies parameter
benja-M-1 authored
414 #### Configuration
415
b7e4cff @fabpot tweaked previous merge
fabpot authored
416 * The 2.2 version introduces a new parameter `trusted_proxies` that replaces
417 `trust_proxy_headers` in the framework configuration.
4d40b11 @benja-M-1 Add notes about kernel.trusted_proxies parameter
benja-M-1 authored
418
419 Before:
420
421 ```
422 # app/config/config.yml
423 framework:
424 trust_proxy_headers: false
425 ```
426
427 After:
428
429 ```
430 # app/config/config.yml
431 framework:
b7e4cff @fabpot tweaked previous merge
fabpot authored
432 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
433 ```
Something went wrong with that request. Please try again.