This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/UPGRADE-4.4.md
Fabien Potencier 4e32643bdf feature #31528 [Validator] Add a Length::$allowEmptyString option to reject empty strings (ogizanagi)
This PR was merged into the 4.4 branch.

Discussion
----------

[Validator] Add a Length::$allowEmptyString option to reject empty strings

| Q             | A
| ------------- | ---
| Branch?       | 4.4 <!-- see below -->
| Bug fix?      | no
| New feature?  | yes <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | yes <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | N/A   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | Todo (change the warning on top of https://symfony.com/doc/current/reference/constraints/Length.html)

which defaults to `true` in 4.4 but will trigger a deprecation if not set explicitly
in order to make the default `false` in 5.0.

While it could be solved now thanks to #29641 by using both `@Length(min=1)` & `@NotBlank(allowNull=true)` constraints,
as expressed in https://github.com/symfony/symfony/issues/27876#issuecomment-403307783 and following comments, the `@Length(min=1)` behavior doesn't match our expectations when reading it: it feels logical to invalidate empty strings, but it actually doesn't.
Hence the proposal of making the behavior of rejecting empty strings the default in 5.0.

In my opinion, the flag could even be removed later.

Commits
-------

e113e7f812 [Validator] Add a Length::$allowEmptyString option to reject empty strings
2019-07-03 15:15:57 +02:00

2.8 KiB

UPGRADE FROM 4.3 to 4.4

DependencyInjection

  • Deprecated support for short factories and short configurators in Yaml

    Before:

    services:
      my_service:
        factory: factory_service:method
    

    After:

    services:
      my_service:
        factory: ['@factory_service', method]
    
  • Deprecated tagged in favor of tagged_iterator

    Before:

    services:
        App\Handler:
            tags: ['app.handler']
    
        App\HandlerCollection:
            arguments: [!tagged app.handler]
    

    After:

    services:
        App\Handler:
        tags: ['app.handler']
    
    App\HandlerCollection:
        arguments: [!tagged_iterator app.handler]
    

Filesystem

  • Support for passing a null value to Filesystem::isAbsolutePath() is deprecated.

Form

  • Using int or float as data for the NumberType when the input option is set to string is deprecated.

FrameworkBundle

  • Deprecated support for templating engine in TemplateController, use Twig instead
  • The $parser argument of ControllerResolver::__construct() and DelegatingLoader::__construct() has been deprecated.
  • The ControllerResolver and DelegatingLoader classes have been marked as final.
  • The controller_name_converter and resolve_controller_name_subscriber services have been deprecated.

HttpClient

  • Added method cancel() to ResponseInterface

HttpFoundation

  • ApacheRequest is deprecated, use Request class instead.

HttpKernel

  • The DebugHandlersListener class has been marked as final

Messenger

  • Deprecated passing a ContainerInterface instance as first argument of the ConsumeMessagesCommand constructor, pass a RoutableMessageBus instance instead.

MonologBridge

  • The RouteProcessor has been marked final.

PropertyAccess

  • Deprecated passing null as 2nd argument of PropertyAccessor::createCache() method ($defaultLifetime), pass 0 instead.

Security

  • Implementations of PasswordEncoderInterface and UserPasswordEncoderInterface should add a new needsRehash() method

TwigBridge

  • Deprecated to pass $rootDir and $fileLinkFormatter as 5th and 6th argument respectively to the DebugCommand::__construct() method, swap the variables position.

Validator

  • Deprecated passing an ExpressionLanguage instance as the second argument of ExpressionValidator::__construct(). Pass it as the first argument instead.
  • The Length constraint expects the allowEmptyString option to be defined when the min option is used. Set it to true to keep the current behavior and false to reject empty strings. In 5.0, it'll become optional and will default to false.