10 KiB
UPGRADE FROM 4.3 to 4.4
Cache
- Added argument
$prefix
toAdapterInterface::clear()
Debug
- Deprecated the
Debug
class, use the one from theErrorRenderer
component instead - Deprecated the
FlattenException
class, use the one from theErrorRenderer
component instead - Deprecated the component in favor of the
ErrorHandler
component
DependencyInjection
-
Made singly-implemented interfaces detection be scoped by file
-
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 oftagged_iterator
Before:
services: App\HandlerCollection: arguments: [!tagged my_tag]
After:
services: App\HandlerCollection: arguments: [!tagged_iterator my_tag]
-
Passing an instance of
Symfony\Component\DependencyInjection\Parameter
as class name toSymfony\Component\DependencyInjection\Definition
is deprecated.Before:
new Definition(new Parameter('my_class'));
After:
new Definition('%my_class%');
DoctrineBridge
- Deprecated injecting
ClassMetadataFactory
inDoctrineExtractor
, an instance ofEntityManagerInterface
should be injected instead. - Deprecated passing an
IdReader
to theDoctrineChoiceLoader
when the query cannot be optimized with single id field. - Deprecated not passing an
IdReader
to theDoctrineChoiceLoader
when the query can be optimized with single id field. - Deprecated
RegistryInterface
, useDoctrine\Common\Persistence\ManagerRegistry
.
Filesystem
- Support for passing a
null
value toFilesystem::isAbsolutePath()
is deprecated.
Form
- Using different values for the "model_timezone" and "view_timezone" options of the
TimeType
without configuring a reference date is deprecated. - Using
int
orfloat
as data for theNumberType
when theinput
option is set tostring
is deprecated. - Overriding the methods
FormIntegrationTestCase::setUp()
,TypeTestCase::setUp()
andTypeTestCase::tearDown()
without thevoid
return-type is deprecated.
FrameworkBundle
- Deprecated booting the kernel before running
WebTestCase::createClient()
. - Deprecated support for
templating
engine inTemplateController
, use Twig instead - The
$parser
argument ofControllerResolver::__construct()
andDelegatingLoader::__construct()
has been deprecated. - The
ControllerResolver
andDelegatingLoader
classes have been marked asfinal
. - The
controller_name_converter
andresolve_controller_name_subscriber
services have been deprecated. - Deprecated
routing.loader.service
, userouting.loader.container
instead. - Not tagging service route loaders with
routing.route_loader
has been deprecated. - Overriding the methods
KernelTestCase::tearDown()
andWebTestCase::tearDown()
without thevoid
return-type is deprecated.
HttpClient
- Added method
cancel()
toResponseInterface
HttpFoundation
ApacheRequest
is deprecated, useRequest
class instead.- Passing a third argument to
HeaderBag::get()
is deprecated since Symfony 4.4, use methodall()
instead PdoSessionHandler
now precalculates the expiry timestamp in the lifetime column, make sure to runCREATE INDEX EXPIRY ON sessions (sess_lifetime)
to update your database to speed up garbage collection of expired sessions.
HttpKernel
-
The
DebugHandlersListener
class has been marked asfinal
-
Added new Bundle directory convention consistent with standard skeletons:
└── MyBundle/ ├── config/ ├── public/ ├── src/ │ └── MyBundle.php ├── templates/ └── translations/
To make this work properly, it is necessary to change the root path of the bundle:
class MyBundle extends Bundle { public function getPath(): string { return \dirname(__DIR__); } }
As many bundles must be compatible with a range of Symfony versions, the current directory convention is not deprecated yet, but it will be in the future.
-
Deprecated the second and third argument of
KernelInterface::locateResource
-
Deprecated the second and third argument of
FileLocator::__construct
-
Deprecated loading resources from
%kernel.root_dir%/Resources
and%kernel.root_dir%
as fallback directories. Resources like service definitions are usually loaded relative to the current directory or with a glob pattern. The fallback directories have never been advocated so you likely do not use those in any app based on the SF Standard or Flex edition.
Lock
- Deprecated
Symfony\Component\Lock\StoreInterface
in favor ofSymfony\Component\Lock\BlockingStoreInterface
andSymfony\Component\Lock\PersistingStoreInterface
. Factory
is deprecated, useLockFactory
instead
Messenger
- Deprecated passing a
ContainerInterface
instance as first argument of theConsumeMessagesCommand
constructor, pass aRoutableMessageBus
instance instead.
Mime
- Removed
NamedAddress
, useAddress
instead (which supports a name now)
MonologBridge
- The
RouteProcessor
has been marked final.
Process
- Deprecated the
Process::inheritEnvironmentVariables()
method: env variables are always inherited.
PropertyAccess
- Deprecated passing
null
as 2nd argument ofPropertyAccessor::createCache()
method ($defaultLifetime
), pass0
instead.
Routing
- Deprecated
ServiceRouterLoader
in favor ofContainerLoader
. - Deprecated
ObjectRouteLoader
in favor ofObjectLoader
.
Security
- The
LdapUserProvider
class has been deprecated, useSymfony\Component\Ldap\Security\LdapUserProvider
instead. - Implementations of
PasswordEncoderInterface
andUserPasswordEncoderInterface
should add a newneedsRehash()
method - Deprecated returning a non-boolean value when implementing
Guard\AuthenticatorInterface::checkCredentials()
. Please explicitly returnfalse
to indicate invalid credentials.
Stopwatch
- Deprecated passing
null
as 1st ($id
) argument ofSection::get()
method, pass a valid child section identifier instead.
Translation
- Deprecated support for using
null
as the locale inTranslator
.
TwigBridge
- Deprecated to pass
$rootDir
and$fileLinkFormatter
as 5th and 6th argument respectively to theDebugCommand::__construct()
method, swap the variables position.
TwigBundle
-
Deprecated default value
twig.controller.exception::showAction
of thetwig.exception_controller
configuration option, set it tonull
instead. This will also change the default error response format according to https://tools.ietf.org/html/rfc7807 forjson
,xml
,atom
andtxt
formats:Before:
{ "error": { "code": 404, "message": "Sorry, the page you are looking for could not be found" } }
After:
{ "title": "Not Found", "status": 404, "detail": "Sorry, the page you are looking for could not be found" }
-
Deprecated the
ExceptionController
and all built-in error templates, use the error renderer mechanism of theErrorRenderer
component -
Deprecated loading custom error templates in non-html formats. Custom HTML error pages based on Twig keep working as before:
Before (
templates/bundles/TwigBundle/Exception/error.jsonld.twig
):{ "@id": "https://example.com", "@type": "error", "@context": { "title": "{{ status_text }}", "code": {{ status_code }}, "message": "{{ exception.message }}" } }
After (
App\ErrorRenderer\JsonLdErrorRenderer
):class JsonLdErrorRenderer implements ErrorRendererInterface { public static function getFormat(): string { return 'jsonld'; } public function render(FlattenException $exception): string { return json_encode([ '@id' => 'https://example.com', '@type' => 'error', '@context' => [ 'title' => $exception->getTitle(), 'code' => $exception->getStatusCode(), 'message' => $exception->getMessage(), ], ]); } }
Configure your rendering service tagging it with error_renderer.renderer
.
Validator
- Deprecated passing an
ExpressionLanguage
instance as the second argument ofExpressionValidator::__construct()
. - Deprecated using anything else than a
string
as the code of aConstraintViolation
, astring
type-hint will be added to the constructor of theConstraintViolation
class and to theConstraintViolationBuilder::setCode()
method in 5.0. - Deprecated passing an
ExpressionLanguage
instance as the second argument ofExpressionValidator::__construct()
. Pass it as the first argument instead. - The
Length
constraint expects theallowEmptyString
option to be defined when themin
option is used. Set it totrue
to keep the current behavior andfalse
to reject empty strings. In 5.0, it'll become optional and will default tofalse
. - Overriding the methods
ConstraintValidatorTestCase::setUp()
andConstraintValidatorTestCase::tearDown()
without thevoid
return-type is deprecated.
WebProfilerBundle
- Deprecated the
ExceptionController
class in favor ofExceptionErrorController
- Deprecated the
TemplateManager::templateExists()
method
WebServerBundle
- The bundle is deprecated and will be removed in 5.0.