Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 386 lines (287 sloc) 11.343 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
60 #### Deprecations
61
62 * The methods `getParent()`, `setParent()` and `hasParent()` in
63 `FormBuilderInterface` were deprecated and will be removed in Symfony 2.3.
64 You should not rely on these methods in your form type because the parent
65 of a form can change after building it.
24c6530 @webmozart [Validator] Added instructions on integrating the latest Validator chang...
webmozart authored
66
51223c0 @Tobion added upgrade instructions
Tobion authored
67 ### Routing
68
69 * RouteCollection does not behave like a tree structure anymore but as a flat
70 array of Routes. So when using PHP to build the RouteCollection, you must
71 make sure to add routes to the sub-collection before adding it to the parent
72 collection (this is not relevant when using YAML or XML for Route definitions).
73
74 Before:
75
76 ```
77 $rootCollection = new RouteCollection();
78 $subCollection = new RouteCollection();
79 $rootCollection->addCollection($subCollection);
80 $subCollection->add('foo', new Route('/foo'));
81 ```
82
83 After:
84
85 ```
86 $rootCollection = new RouteCollection();
87 $subCollection = new RouteCollection();
88 $subCollection->add('foo', new Route('/foo'));
89 $rootCollection->addCollection($subCollection);
90 ```
91
92 Also one must call `addCollection` from the bottom to the top hierarchy.
93 So the correct sequence is the following (and not the reverse):
94
95 ```
96 $childCollection->->addCollection($grandchildCollection);
97 $rootCollection->addCollection($childCollection);
98 ```
99
100 * The methods `RouteCollection::getParent()` and `RouteCollection::getRoot()`
101 have been deprecated and will be removed in Symfony 2.3.
8c7a169 @Tobion [Routing] clean up of RouteCollection API
Tobion authored
102 * Misusing the `RouteCollection::addPrefix` method to add defaults, requirements
103 or options without adding a prefix is not supported anymore. So if you called `addPrefix`
104 with an empty prefix or `/` only (both have no relevance), like
105 `addPrefix('', $defaultsArray, $requirementsArray, $optionsArray)`
106 you need to use the new dedicated methods `addDefaults($defaultsArray)`,
107 `addRequirements($requirementsArray)` or `addOptions($optionsArray)` instead.
108 * The `$options` parameter to `RouteCollection::addPrefix()` has been deprecated
109 because adding options has nothing to do with adding a path prefix. If you want to add options
110 to all child routes of a RouteCollection, you can use `addOptions()`.
111 * The method `RouteCollection::getPrefix()` has been deprecated
112 because it suggested that all routes in the collection would have this prefix, which is
113 not necessarily true. On top of that, since there is no tree structure anymore, this method
114 is also useless.
115 * `RouteCollection::addCollection(RouteCollection $collection)` should now only be
116 used with a single parameter. The other params `$prefix`, `$default`, `$requirements` and `$options`
117 will still work, but have been deprecated. The `addPrefix` method should be used for this
118 use-case instead.
119 Before: `$parentCollection->addCollection($collection, '/prefix', array(...), array(...))`
120 After:
121 ```
122 $collection->addPrefix('/prefix', array(...), array(...));
123 $parentCollection->addCollection($collection);
124 ```
51223c0 @Tobion added upgrade instructions
Tobion authored
125
24c6530 @webmozart [Validator] Added instructions on integrating the latest Validator chang...
webmozart authored
126 ### Validator
127
1db6f05 @ragtek Update UPGRADE-2.2.md
ragtek authored
128 * Interfaces were created for the classes `ConstraintViolation`,
24c6530 @webmozart [Validator] Added instructions on integrating the latest Validator chang...
webmozart authored
129 `ConstraintViolationList`, `GlobalExecutionContext` and `ExecutionContext`.
130 If you type hinted against any of these classes, you are recommended to
131 type hint against their interfaces now.
132
133 Before:
134
135 ```
136 use Symfony\Component\Validator\ExecutionContext;
137
138 public function validateCustomLogic(ExecutionContext $context)
139 ```
140
141 After:
142
143 ```
fae3e35 @fabpot fixed typo
fabpot authored
144 use Symfony\Component\Validator\ExecutionContextInterface;
24c6530 @webmozart [Validator] Added instructions on integrating the latest Validator chang...
webmozart authored
145
146 public function validateCustomLogic(ExecutionContextInterface $context)
147 ```
148
149 For all implementations of `ConstraintValidatorInterface`, this change is
150 mandatory for the `initialize` method:
151
152 Before:
153
154 ```
155 use Symfony\Component\Validator\ConstraintValidatorInterface;
156 use Symfony\Component\Validator\ExecutionContext;
157
158 class MyValidator implements ConstraintValidatorInterface
159 {
160 public function initialize(ExecutionContext $context)
161 {
162 // ...
163 }
164 }
165 ```
166
167 After:
168
169 ```
170 use Symfony\Component\Validator\ConstraintValidatorInterface;
171 use Symfony\Component\Validator\ExecutionContextInterface;
172
173 class MyValidator implements ConstraintValidatorInterface
174 {
175 public function initialize(ExecutionContextInterface $context)
176 {
177 // ...
178 }
179 }
180 ```
181
182 #### Deprecations
183
184 * The interface `ClassMetadataFactoryInterface` was deprecated and will be
185 removed in Symfony 2.3. You should implement `MetadataFactoryInterface`
186 instead, which changes the name of the method `getClassMetadata` to
187 `getMetadataFor` and accepts arbitrary values (e.g. class names, objects,
188 numbers etc.). In your implementation, you should throw a
189 `NoSuchMetadataException` if you don't support metadata for the given value.
190
191 Before:
192
193 ```
194 use Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface;
195
196 class MyMetadataFactory implements ClassMetadataFactoryInterface
197 {
198 public function getClassMetadata($class)
199 {
200 // ...
201 }
202 }
203 ```
204
205 After:
206
207 ```
208 use Symfony\Component\Validator\MetadataFactoryInterface;
209 use Symfony\Component\Validator\Exception\NoSuchMetadataException;
210
211 class MyMetadataFactory implements MetadataFactoryInterface
212 {
213 public function getMetadataFor($value)
214 {
215 if (is_object($value)) {
216 $value = get_class($value);
217 }
218
219 if (!is_string($value) || (!class_exists($value) && !interface_exists($value))) {
220 throw new NoSuchMetadataException(...);
221 }
222
223 // ...
224 }
225 }
226 ```
227
228 The return value of `ValidatorInterface::getMetadataFactory()` was also
229 changed to return `MetadataFactoryInterface`. Make sure to replace calls to
230 `getClassMetadata` by `getMetadataFor` on the return value of this method.
231
232 Before:
233
234 ```
235 $metadataFactory = $validator->getMetadataFactory();
236 $metadata = $metadataFactory->getClassMetadata('Vendor\MyClass');
237 ```
238
239 After:
240
241 ```
242 $metadataFactory = $validator->getMetadataFactory();
243 $metadata = $metadataFactory->getMetadataFor('Vendor\MyClass');
244 ```
245
246 * The class `GraphWalker` and the accessor `ExecutionContext::getGraphWalker()`
247 were deprecated and will be removed in Symfony 2.3. You should use the
248 methods `ExecutionContextInterface::validate()` and
249 `ExecutionContextInterface::validateValue()` instead.
250
251 Before:
252
253 ```
254 use Symfony\Component\Validator\ExecutionContext;
255
256 public function validateCustomLogic(ExecutionContext $context)
257 {
258 if (/* ... */) {
259 $path = $context->getPropertyPath();
260 $group = $context->getGroup();
261
262 if (!empty($path)) {
263 $path .= '.';
264 }
265
266 $context->getGraphWalker()->walkReference($someObject, $group, $path . 'myProperty', false);
267 }
268 }
269 ```
270
271 After:
272
273 ```
274 use Symfony\Component\Validator\ExecutionContextInterface;
275
276 public function validateCustomLogic(ExecutionContextInterface $context)
277 {
278 if (/* ... */) {
279 $context->validate($someObject, 'myProperty');
280 }
281 }
282 ```
283
284 * The method `ExecutionContext::addViolationAtSubPath()` was deprecated and
285 will be removed in Symfony 2.3. You should use `addViolationAt()` instead.
286
287 Before:
288
289 ```
290 use Symfony\Component\Validator\ExecutionContext;
291
292 public function validateCustomLogic(ExecutionContext $context)
293 {
294 if (/* ... */) {
295 $context->addViolationAtSubPath('myProperty', 'This value is invalid');
296 }
297 }
298 ```
299
300 After:
301
302 ```
303 use Symfony\Component\Validator\ExecutionContextInterface;
304
305 public function validateCustomLogic(ExecutionContextInterface $context)
306 {
307 if (/* ... */) {
308 $context->addViolationAt('myProperty', 'This value is invalid');
309 }
310 }
311 ```
312
313 * The methods `ExecutionContext::getCurrentClass()`, `ExecutionContext::getCurrentProperty()`
314 and `ExecutionContext::getCurrentValue()` were deprecated and will be removed
315 in Symfony 2.3. Use the methods `getClassName()`, `getPropertyName()` and
316 `getValue()` instead.
317
318 Before:
319
320 ```
321 use Symfony\Component\Validator\ExecutionContext;
322
323 public function validateCustomLogic(ExecutionContext $context)
324 {
325 $class = $context->getCurrentClass();
326 $property = $context->getCurrentProperty();
327 $value = $context->getCurrentValue();
328
329 // ...
330 }
331 ```
332
333 After:
334
335 ```
336 use Symfony\Component\Validator\ExecutionContextInterface;
337
338 public function validateCustomLogic(ExecutionContextInterface $context)
339 {
340 $class = $context->getClassName();
341 $property = $context->getPropertyName();
342 $value = $context->getValue();
343
344 // ...
345 }
346 ```
9071676 @ricardclau create oneof constraint and add deprecation messages in choice, also mak...
ricardclau authored
347
348 * The constraint `Choice` was deprecated and will be removed in Symfony 2.3.
349 You should use the new constraint `OneOf` instead.
350
351 Before:
352
353 ```
354 /** @Assert\Choice(choices = {"male", "female"}, message = "Choose a valid gender.") */
355 protected $gender;
356 ```
357
358 After:
359
360 ```
361 /** @Assert\OneOf(choices = {"male", "female"}, message = "Choose a valid gender.") */
362 protected $gender;
363 ```
364
4d40b11 @benja-M-1 Add notes about kernel.trusted_proxies parameter
benja-M-1 authored
365 ### FrameworkBundle
366
367 #### Configuration
368
369 * The 2.2 version introduces a new parameter ```trusted_proxies``` that replaces ```trust_proxy_headers``` in the framework configuration.
370
371 Before:
372
373 ```
374 # app/config/config.yml
375 framework:
376 trust_proxy_headers: false
377 ```
378
379 After:
380
381 ```
382 # app/config/config.yml
383 framework:
384 trusted_proxies: []
385 ```
Something went wrong with that request. Please try again.