1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632
|
UPGRADE FROM 2.7 to 2.8
=======================
All components
--------------
* Symfony now requires the iconv extension to be present, which is the case by
default in most environments. However, if you're not able to ensure this
extension to be installed in your target environment, you can add Symfony's
iconv polyfill to your project's composer.json file.
```json
"require": {
"symfony/polyfill-iconv": "~1.0"
}
```
Form
----
* The `intention` option was deprecated and will be removed in 3.0 in favor
of the new `csrf_token_id` option.
* The `csrf_provider` option was deprecated and will be removed in 3.0 in favor
of the new `csrf_token_manager` option.
* The "cascade_validation" option was deprecated. Use the "constraints"
option together with the `Valid` constraint instead. Contrary to
"cascade_validation", "constraints" must be set on the respective child forms,
not the parent form.
Before:
```php
$form = $this->createFormBuilder($article, array('cascade_validation' => true))
->add('author', new AuthorType())
->getForm();
```
After:
```php
use Symfony\Component\Validator\Constraints\Valid;
$form = $this->createFormBuilder($article)
->add('author', new AuthorType(), array(
'constraints' => new Valid(),
))
->getForm();
```
Alternatively, you can set the `Valid` constraint in the model itself:
```php
use Symfony\Component\Validator\Constraints as Assert;
class Article
{
/**
* @Assert\Valid
*/
private $author;
}
```
* Type names were deprecated and will be removed in Symfony 3.0. Instead of
referencing types by name, you should reference them by their
fully-qualified class name (FQCN) instead. With PHP 5.5 or later, you can
use the "class" constant for that:
Before:
```php
$form = $this->createFormBuilder()
->add('name', 'text')
->add('age', 'integer')
->getForm();
```
After:
```php
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
$form = $this->createFormBuilder()
->add('name', TextType::class)
->add('age', IntegerType::class)
->getForm();
```
As a further consequence, the method `FormTypeInterface::getName()` was
deprecated and will be removed in Symfony 3.0. You should remove this method
from your form types.
If you want to customize the block prefix of a type in Twig, you should now
implement `FormTypeInterface::getBlockPrefix()` instead:
Before:
```php
class UserProfileType extends AbstractType
{
public function getName()
{
return 'profile';
}
}
```
After:
```php
class UserProfileType extends AbstractType
{
public function getBlockPrefix()
{
return 'profile';
}
}
```
If you don't customize `getBlockPrefix()`, it defaults to the class name
without "Type" suffix in underscore notation (here: "user_profile").
If you want to create types that are compatible with Symfony 2.3 up to 2.8
and don't trigger deprecation errors, implement *both* `getName()` and
`getBlockPrefix()`:
```php
class ProfileType extends AbstractType
{
public function getName()
{
return $this->getBlockPrefix();
}
public function getBlockPrefix()
{
return 'profile';
}
}
```
If you define your form types in the Dependency Injection configuration, you
should further remove the "alias" attribute:
Before:
```xml
<service id="my.type" class="Vendor\Type\MyType">
<tag name="form.type" alias="mytype" />
</service>
```
After:
```xml
<service id="my.type" class="Vendor\Type\MyType">
<tag name="form.type" />
</service>
```
Type extension should return the fully-qualified class name of the extended
type from `FormTypeExtensionInterface::getExtendedType()` now.
Before:
```php
class MyTypeExtension extends AbstractTypeExtension
{
public function getExtendedType()
{
return 'form';
}
}
```
After:
```php
use Symfony\Component\Form\Extension\Core\Type\FormType;
class MyTypeExtension extends AbstractTypeExtension
{
public function getExtendedType()
{
return FormType::class;
}
}
```
If your extension has to be compatible with Symfony 2.3-2.8, use the
following statement:
```php
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\FormType;
class MyTypeExtension extends AbstractTypeExtension
{
public function getExtendedType()
{
return method_exists(AbstractType::class, 'getBlockPrefix') ? FormType::class : 'form';
}
}
```
* In Symfony 2.7 a small BC break was introduced with the new choices_as_values
option. In order to have the choice values populated to the html value attribute
you had to define the choice_value option. This is now not any more needed.
Before:
```php
$form->add('status', 'choice', array(
'choices' => array(
'Enabled' => Status::ENABLED,
'Disabled' => Status::DISABLED,
'Ignored' => Status::IGNORED,
),
'choices_as_values' => true,
// important if you rely on your option value attribute (e.g. for JavaScript)
// this will keep the same functionality as before
'choice_value' => function ($choice) {
return $choice;
},
));
```
After (Symfony 2.8+):
```php
$form->add('status', ChoiceType::class, array(
'choices' => array(
'Enabled' => Status::ENABLED,
'Disabled' => Status::DISABLED,
'Ignored' => Status::IGNORED,
),
'choices_as_values' => true
));
```
* Returning type instances from `FormTypeInterface::getParent()` is deprecated
and will not be supported anymore in Symfony 3.0. Return the fully-qualified
class name of the parent type class instead.
Before:
```php
class MyType
{
public function getParent()
{
return new ParentType();
}
}
```
After:
```php
class MyType
{
public function getParent()
{
return ParentType::class;
}
}
```
* The option "options" of the CollectionType has been renamed to "entry_options".
The usage of the option "options" is deprecated and will be removed in Symfony 3.0.
* The option "type" of the CollectionType has been renamed to "entry_type".
The usage of the option "type" is deprecated and will be removed in Symfony 3.0.
As a value for the option you should provide the fully-qualified class name (FQCN)
now as well.
* Passing type instances to `Form::add()`, `FormBuilder::add()` and the
`FormFactory::create*()` methods is deprecated and will not be supported
anymore in Symfony 3.0. Pass the fully-qualified class name of the type
instead.
Before:
```php
$form = $this->createForm(new MyType());
```
After:
```php
$form = $this->createForm(MyType::class);
```
* Registering type extensions as a service with an alias which does not
match the type returned by `getExtendedType` is now forbidden. Fix your
implementation to define the right type.
* The alias option of the `form.type_extension` tag is deprecated in favor of
the `extended_type`/`extended-type` option.
Before:
```xml
<service id="app.type_extension" class="Vendor\Form\Extension\MyTypeExtension">
<tag name="form.type_extension" alias="text" />
</service>
```
After:
```xml
<service id="app.type_extension" class="Vendor\Form\Extension\MyTypeExtension">
<tag name="form.type_extension" extended-type="Symfony\Component\Form\Extension\Core\Type\TextType" />
</service>
```
* The `TimezoneType::getTimezones()` method was deprecated and will be removed
in Symfony 3.0. You should not use this method.
* The class `ArrayKeyChoiceList` was deprecated and will be removed in Symfony
3.0. Use `ArrayChoiceList` instead.
Translator
----------
* The `getMessages()` method of the `Symfony\Component\Translation\Translator` was deprecated and will be removed in
Symfony 3.0. You should use the `getCatalogue()` method of the `Symfony\Component\Translation\TranslatorBagInterface`.
Before:
```php
$messages = $translator->getMessages();
```
After:
```php
$catalogue = $translator->getCatalogue($locale);
$messages = $catalogue->all();
while ($catalogue = $catalogue->getFallbackCatalogue()) {
$messages = array_replace_recursive($catalogue->all(), $messages);
}
```
DependencyInjection
-------------------
* The concept of scopes were deprecated, the deprecated methods are:
- `Symfony\Component\DependencyInjection\ContainerBuilder::getScopes()`
- `Symfony\Component\DependencyInjection\ContainerBuilder::getScopeChildren()`
- `Symfony\Component\DependencyInjection\ContainerInterface::enterScope()`
- `Symfony\Component\DependencyInjection\ContainerInterface::leaveScope()`
- `Symfony\Component\DependencyInjection\ContainerInterface::addScope()`
- `Symfony\Component\DependencyInjection\ContainerInterface::hasScope()`
- `Symfony\Component\DependencyInjection\ContainerInterface::isScopeActive()`
- `Symfony\Component\DependencyInjection\Definition::setScope()`
- `Symfony\Component\DependencyInjection\Definition::getScope()`
- `Symfony\Component\DependencyInjection\Reference::isStrict()`
Also, the `$scope` and `$strict` parameters of `Symfony\Component\DependencyInjection\ContainerInterface::set()` and `Symfony\Component\DependencyInjection\Reference` respectively were deprecated.
* A new `shared` flag has been added to the service definition
in replacement of the `prototype` scope.
Before:
```php
use Symfony\Component\DependencyInjection\ContainerBuilder;
$container = new ContainerBuilder();
$container
->register('foo', 'stdClass')
->setScope(ContainerBuilder::SCOPE_PROTOTYPE)
;
```
```yml
services:
foo:
class: stdClass
scope: prototype
```
```xml
<services>
<service id="foo" class="stdClass" scope="prototype" />
</services>
```
After:
```php
use Symfony\Component\DependencyInjection\ContainerBuilder;
$container = new ContainerBuilder();
$container
->register('foo', 'stdClass')
->setShared(false)
;
```
```yml
services:
foo:
class: stdClass
shared: false
```
```xml
<services>
<service id="foo" class="stdClass" shared="false" />
</services>
```
* `Symfony\Component\DependencyInjection\ContainerAware` has been deprecated, use
`Symfony\Component\DependencyInjection\ContainerAwareTrait` or implement
`Symfony\Component\DependencyInjection\ContainerAwareInterface` manually
WebProfiler
-----------
* The `profiler:import` and `profiler:export` commands have been deprecated and
will be removed in 3.0.
* The web development toolbar has been completely redesigned. This update has
introduced some changes in the HTML markup of the toolbar items.
Before:
Information was wrapped with simple `<span>` elements:
```twig
{% block toolbar %}
{% set icon %}
<span>
<svg ...></svg>
<span>{{ '%.1f'|format(collector.memory / 1024 / 1024) }} MB</span>
</span>
{% endset %}
{% endblock %}
```
After:
Information is now semantically divided into values and labels according to
the `class` attribute of each `<span>` element:
```twig
{% block toolbar %}
{% set icon %}
<svg ...></svg>
<span class="sf-toolbar-value">
{{ '%.1f'|format(collector.memory / 1024 / 1024) }}
</span>
<span class="sf-toolbar-label">MB</span>
{% endset %}
{% endblock %}
```
Most of the blocks designed for the previous toolbar will still be displayed
correctly. However, if you want to support both the old and the new toolbar,
it's better to make use of the new `profiler_markup_version` variable passed
to the toolbar templates:
```twig
{% block toolbar %}
{% set profiler_markup_version = profiler_markup_version|default(1) %}
{% set icon %}
{% if profiler_markup_version == 1 %}
{# code for the original toolbar #}
{% else %}
{# code for the new toolbar (Symfony 2.8+) #}
{% endif %}
{% endset %}
{% endblock %}
```
* All the profiler storages different than `FileProfilerStorage` have been
deprecated. The deprecated classes are:
- `Symfony\Component\HttpKernel\Profiler\BaseMemcacheProfilerStorage`
- `Symfony\Component\HttpKernel\Profiler\MemcachedProfilerStorage`
- `Symfony\Component\HttpKernel\Profiler\MemcacheProfilerStorage`
- `Symfony\Component\HttpKernel\Profiler\MongoDbProfilerStorage`
- `Symfony\Component\HttpKernel\Profiler\MysqlProfilerStorage`
- `Symfony\Component\HttpKernel\Profiler\PdoProfilerStorage`
- `Symfony\Component\HttpKernel\Profiler\RedisProfilerStorage`
- `Symfony\Component\HttpKernel\Profiler\SqliteProfilerStorage`
The alternative solution is to use the `FileProfilerStorage` or create your
own storage implementing the `ProfileStorageInterface`.
FrameworkBundle
---------------
* The default value of the parameter `session`.`cookie_httponly` is now `true`.
It prevents scripting languages, such as JavaScript to access the cookie,
which help to reduce identity theft through XSS attacks. If your
application needs to access the session cookie, override this parameter:
```yaml
framework:
session:
cookie_httponly: false
```
* The `validator.mapping.cache.apc` service is deprecated, and will be removed in 3.0.
Use `validator.mapping.cache.doctrine.apc` instead.
* The ability to pass `apc` as the `framework.validation.cache` configuration key value is deprecated,
and will be removed in 3.0. Use `validator.mapping.cache.doctrine.apc` instead:
Before:
```yaml
framework:
validation:
cache: apc
```
After:
```yaml
framework:
validation:
cache: validator.mapping.cache.doctrine.apc
```
Security
--------
* The `object` variable passed to expressions evaluated by the `ExpressionVoter`
is deprecated. Instead use the new `subject` variable.
* The `AbstractVoter` class was deprecated. Instead, extend the `Voter` class and
move your voting logic in the `supports($attribute, $subject)` and
`voteOnAttribute($attribute, $object, TokenInterface $token)` methods.
* The `VoterInterface::supportsClass` and `supportsAttribute` methods were
deprecated and will be removed from the interface in 3.0.
* The `intention` option is deprecated for all the authentication listeners,
and will be removed in 3.0. Use the `csrf_token_id` option instead.
* The `csrf_provider` option is deprecated for all the authentication listeners,
and will be removed in 3.0. Use the `csrf_token_generator` option instead.
SecurityBundle
--------------
* The `intention` firewall listener setting is deprecated, and will be removed in 3.0.
Use the `csrf_token_id` option instead.
* The `csrf_provider` firewall listener setting is deprecated, and will be removed in 3.0.
Use the `csrf_token_generator` option instead.
Config
------
* The `\Symfony\Component\Config\Resource\ResourceInterface::isFresh()` method has been
deprecated and will be removed in Symfony 3.0 because it assumes that resource
implementations are able to check themselves for freshness.
If you have custom resources that implement this method, change them to implement the
`\Symfony\Component\Config\Resource\SelfCheckingResourceInterface` sub-interface instead
of `\Symfony\Component\Config\Resource\ResourceInterface`.
Before:
```php
use Symfony\Component\Config\Resource\ResourceInterface;
class MyCustomResource implements ResourceInterface { ... }
```
After:
```php
use Symfony\Component\Config\Resource\SelfCheckingResourceInterface;
class MyCustomResource implements SelfCheckingResourceInterface { ... }
```
Additionally, if you have implemented cache validation strategies *using* `isFresh()`
yourself, you should have a look at the new cache validation system based on
`ResourceChecker`s.
Yaml
----
* Deprecated usage of a colon in an unquoted mapping value
* Deprecated usage of `@`, `` ` ``, `|`, and `>` at the beginning of an unquoted string
* When surrounding strings with double-quotes, you must now escape `\` characters. Not
escaping those characters (when surrounded by double-quotes) is deprecated.
Before:
```yml
class: "Foo\Var"
```
After:
```yml
class: "Foo\\Var"
```
HttpFoundation
--------------
* Deprecated finding deep items in `ParameterBag::get()`. This may affect you
when getting parameters from the `Request` class:
Before:
```php
$request->query->get('foo[bar]', null, true);
```
After:
```php
$request->query->get('foo')[bar];
```
|