Preparing Pimcore for Version 11
Upgrade to Pimcore 10.6
- Upgrade to version 10.6.x, if you are using a lower version.
Migrate PHP Templates to Twig
With Pimcore 11, it is required to update your PHP templates to Twig.
Be aware that Pimcore 11 does not support installing pimcore/php-templating-engine-bundle
anymore. The migration to Twig is then required even for enterprise customers.
You can use a RegEx to replace strings in your template files. For example, rewrite {% extends ':Layout:default.html.twig' %}
to {% extends 'Layout/default.html.twig' %}
.
Better replace the strings manually with your IDE instead of as a batch process.
Code Changes
-
[Type hints] Check and add return type hints for classes extending Pimcore classes or implementing interfaces provided by Pimcore, based on the source phpdoc or comments on the methods. The return types will be added to Pimcore classes, so you must add return types to your classes extending Pimcore. You could use the patch-type-declarations tool, provided by symfony, to check for affected methods. For details please have a look here.
-
[Javascript] Replace plugins with event listener as follows:
pimcore.registerNS("pimcore.plugin.MyTestBundle");
pimcore.plugin.MyTestBundle = Class.create(pimcore.plugin.admin, {
getClassName: function () {
return "pimcore.plugin.MyTestBundle";
},
initialize: function () {
pimcore.plugin.broker.registerPlugin(this);
},
preSaveObject: function (object, type) {
var userAnswer = confirm("Are you sure you want to save " + object.data.general.className + "?");
if (!userAnswer) {
throw new pimcore.error.ActionCancelledException('Cancelled by user');
}
}
});
var MyTestBundlePlugin = new pimcore.plugin.MyTestBundle();document.addEventListener(pimcore.events.preSaveObject, (e) => {
let userAnswer = confirm(`Are you sure you want to save ${e.detail.object.data.general.className}?`);
if (!userAnswer) {
e.preventDefault();
e.stopPropagation();
pimcore.helpers.showNotification(t("Info"), t("saving_failed") + ' ' + 'placeholder', 'info');
}
}); -
[Javascript] Replace deprecated JS functions:
- Use t() instead of ts() for translations.
- Stop using
pimcore.helpers.addCsrfTokenToUrl
-
[Deprecations] Fix deprecations defined in the upgrade notes, which is to be removed in Pimcore 11. Tip: you can search for deprecations in Symfony Profiler(Debug mode) or can run linux command
tail -f var/log/dev.log | grep 'User Deprecated'
for checking deprecations on runtime. -
[Extensions] Stop using
var/config/extensions.php
for registering bundles, useconfig/bundle.php
instead. -
Don't use deprecated
Pimcore\Db\ConnectionInterface
interface,Pimcore\Db\Connection
class andPimcore\Db\PimcoreExtensionsTrait
trait UseDoctrine\DBAL\Driver\Connection
interface andDoctrine\DBAL\Connection
class instead. Some methods must be replaced:- Use
executeQuery()
instead ofquery()
- Use
executeStatement()
instead ofexecuteUpdate()
,deleteWhere()
,updateWhere()
- Use
fetchAssociative()
instead offetchRow()
- Use
fetchFirstColumn()
instead offetchCol()
- Use
Pimcore\Db\Helper::fetchPairs()
instead offetchPairs()
- Use
Pimcore\Db\Helper::upsert()
instead ofinsertOrUpdate()
- Use
Pimcore\Db\Helper::quoteInto()
instead ofquoteInto()
- Use
quoteIdentifier()
instead ofquoteColumnAs()
- Don't use
quoteTableAs()
- Don't use
limit()
- Use
Pimcore\Db\Helper::queryIgnoreError()
instead ofqueryIgnoreError()
- Use
Pimcore\Db\Helper::selectAndDeleteWhere()
instead ofselectAndDeleteWhere()
- Use
Pimcore\Db\Helper::escapeLike()
instead ofescapeLike()
- Use
-
[Ecommerce] Switch to ElasticSearch8 implementations in case you are using elasticsearch indices.
-
[Symfony]
- Require
symfony/dotenv
package in your project to keep using.env
files and stop usingPIMCORE_SKIP_DOTENV_FILE
env var as by default it is skipped. You still could use environment specific file like.env.test
or.env.prod
for environment specific environment variables.composer require --no-update symfony/dotenv
- Require
-
[Deprecations] Constant
PIMCORE_PHP_ERROR_LOG
is deprecated and will be removed in Pimcore 11
Migrations
Make sure that migrations are executed.
How to handle them highly depends on your deployment process.
You can manually call bin/console doctrine:migrations:migrate
at any time or add it in your deployment pipeline.
If you are sure you can run all available migrations after composer update
, including bundles and your app-specific migrations, just include the following part in your composer.json
file:
"post-update-cmd": [
"./bin/console doctrine:migrations:migrate"
]
Configuration Adaptions
-
[Security] Enable New Security Authenticator and adapt your
security.yaml
file as per changes here:security:
enable_authenticator_manager: truePoints to consider when moving to new Authenticator:
- New authentication system works with password hasher factory instead of encoder factory.
- BruteforceProtectionHandler will be replaced with Login Throttling.
- Custom Guard Authenticator will be replaced with Http\Authenticator.
-
[Config Environment] Replace deprecated setting write targets and storage directory in the .env file with symfony config
PIMCORE_WRITE_TARGET_IMAGE_THUMBNAILS=symfony-config
PIMCORE_WRITE_TARGET_CUSTOM_REPORTS=settings-store
PIMCORE_CONFIG_STORAGE_DIR_IMAGE_THUMBNAILS=/var/www/html/var/config/image-thumbnailsFor example, see the Demo Configuration.
pimcore:
config_location:
image_thumbnails:
write_target:
type: 'symfony-config'
options:
directory: '/var/www/html/var/config/image-thumbnails'
document_types:
write_target:
type: 'settings-store'
# other available write targets are the following
# video_thumbnails:
# web_to_print:
# predefined_properties:
# staticroutes:
# perspectives:
# custom_views:
# object_custom_layouts:
# predefined_asset_metadata:You might also adapt the
config_location
from other extensions, like Datahub.
Migrate o_ prefix properties in the stored data
As o_
prefix will be removed from data objects system properties in v11. It is recommended to migrate the stored data to use new properties (without o_ prefix).
Please adapt and use these scripts to migrate versions and recycle-bin data.
Additional Things to Consider
- [Web2Print] Please keep in mind that the deprecated processor
HeadlessChrome
needs to be replaced with the new processorChrome
in Pimcore 11. - [Config]
pimcore.assets.image.focal_point_detection
was removed - [Composer] Please make sure to add the
pimcore/compatibility-bridge-v10
to your composer.json file:This package provides backward compatibility layer for some Pimcore 10 classes.composer require --no-update pimcore/compatibility-bridge-v10
- [Definition Files] Make sure your definition files in
var/classes
are up-to-date and all default values are set correctly by running following migration:bin/console doctrine:migration:exec 'Pimcore\Bundle\CoreBundle\Migrations\Version20230508121105'