Skip to main content
page last edited on 24 April 2023

Migration guide 5.5.0 -> 5.5.1

Version: 5.5.1

System requirements and environment setup

  • php 7.4 support has been discontinued; supported php versions: php 8.0 - 8.2
  • The ability to configure the web server in the project root folder has been removed. The web server must now be configured in the public folder. Configuration examples can be found in the docs folder.

3rd party libraries

Removed

  • fig/link-util - (dependency for api-platform/core)

Added

  • gesdinet/jwt-refresh-token-bundle -> v1.1.1
  • giggsey/libphonenumber-for-php -> 8.13.4
  • sensio/framework-extra-bundle -> v6.2.9
  • giggsey/locale -> 2.3 (dependency for giggsey/libphonenumber-for-php)
  • psr/clock -> 1.0.0 (dependency for lexik/jwt-authentication-bundle)
  • psr/http-factory -> 1.0.1 (dependency for firebase/php-jwt)
  • stella-maris/clock -> 0.1.7 (dependency for lexik/jwt-authentication-bundle)

Internal libraries for Storefront API

  • xcart/api-platform-bridge-bundle -> 5.5.1.x-dev
  • xcart/common-bundle -> 5.5.1.x-dev
  • xcart/doctrine-bridge-bundle -> 5.5.1.x-dev
  • xcart/dto-generator-bundle -> 5.5.1.x-dev
  • xcart/logic-bundle -> 5.5.1.x-dev
  • php-ds/php-ds -> v1.4.1 (dependency for xcart/logic-bundle)
  • symfony/lock -> v5.4.15 (dependency for xcart/logic-bundle)
  • ramsey/uuid-doctrine -> 1.8.2 (dependency for xcart/doctrine-bridge-bundle)
  • brick/math -> 0.10.2 (dependency for xcart/common-bundle)
  • jms/metadata -> 2.7.0 (dependency for xcart/common-bundle)
  • jms/serializer -> 3.18.2 (dependency for xcart/common-bundle)
  • jms/serializer-bundle -> 5.0.2 (dependency for xcart/common-bundle)
  • myclabs/php-enum -> 1.8.4 (dependency for xcart/common-bundle)
  • ramsey/collection -> 1.2.2 (dependency for xcart/common-bundle)
  • ramsey/uuid -> 4.7.0 (dependency for xcart/common-bundle)

Updated

  • api-platform/core - v2.6.8 -> v2.7.5
  • aws/aws-sdk-php - 3.209.3 -> 3.255.3
  • doctrine/annotations - 1.13.2 -> 1.14.2
  • doctrine/doctrine-bundle - 2.5.5 -> 2.7.2
  • doctrine/doctrine-migrations-bundle - 3.2.1 -> 3.2.2
  • doctrine/orm - 2.10.4 -> 2.14.0
  • ezyang/htmlpurifier - v4.14.0 -> v4.16.0
  • firebase/php-jwt - v5.5.1 -> v6.3.2
  • guzzlehttp/guzzle - 7.4.1 -> 7.5.0
  • jbroadway/urlify - 1.2.2-stable -> 1.2.4-stable
  • laminas/laminas-code - 4.5.1 -> 4.7.2
  • lexik/jwt-authentication-bundle - v2.14.4 -> v2.16.0
  • lsolesen/pel - 0.9.10 -> 0.9.12
  • maxbanton/cwh - v2.0.2 -> v2.0.4
  • mobiledetect/mobiledetectlib - 2.8.37 -> 3.74.0
  • php-amqplib/php-amqplib - v3.1.1 -> v3.4.0
  • phpmailer/phpmailer - v6.5.3 -> v6.7.1
  • phpseclib/phpseclib - 2.0.35 -> 2.0.41
  • symfony/amqp-messenger - v5.4.0 -> v5.4.15
  • symfony/asset - v5.4.0 -> v5.4.13
  • symfony/cache - v5.4.2 -> v5.4.15
  • symfony/config - v5.4.2 -> v5.4.11
  • symfony/console - v5.4.2 -> v5.4.16
  • symfony/css-selector - v5.4.3 -> v5.4.11
  • symfony/debug-bundle - v5.4.3 -> v5.4.11
  • symfony/dependency-injection - v5.4.2 -> v5.4.16
  • symfony/doctrine-bridge - v5.4.2 -> v5.4.16
  • symfony/doctrine-messenger - v5.4.0 -> v5.4.16
  • symfony/dotenv - v5.4.2 -> v5.4.5
  • symfony/error-handler - v5.4.2 -> v5.4.15
  • symfony/event-dispatcher - v5.4.0 -> v5.4.9
  • symfony/expression-language - v5.4.0 -> v5.4.14
  • symfony/filesystem - v5.4.0 -> v5.4.13
  • symfony/finder - v5.4.2 -> v5.4.11
  • symfony/flex - v1.18.1 -> v1.18.7
  • symfony/form - v5.4.2 -> v5.4.16
  • symfony/framework-bundle - v5.4.2 -> v5.4.16
  • symfony/http-foundation - v5.4.2 -> v5.4.16
  • symfony/http-kernel - v5.4.2 -> v5.4.16
  • symfony/messenger - v5.4.2 -> v5.4.16
  • symfony/monolog-bridge - v5.4.0 -> v5.4.10
  • symfony/monolog-bundle - v3.7.1 -> v3.8.0
  • symfony/options-resolver - v5.4.0 -> v5.4.11
  • symfony/password-hasher - v5.4.2 -> v5.4.11
  • symfony/process - v5.4.2 -> v5.4.11
  • symfony/property-access - v5.4.2 -> v5.4.15
  • symfony/property-info - v5.4.2 -> v5.4.16
  • symfony/proxy-manager-bridge - v5.4.2 -> v5.4.6
  • symfony/redis-messenger - v5.4.2 -> v5.4.15
  • symfony/routing - v5.4.0 -> v5.4.15
  • symfony/runtime - v5.4.1 -> v5.4.11
  • symfony/security-bundle - v5.4.2 -> v5.4.11
  • symfony/security-core - v5.4.2 -> v5.4.15
  • symfony/security-csrf - v5.4.0 -> v5.4.11
  • symfony/security-guard - v5.4.0 -> v5.4.13
  • symfony/security-http - v5.4.2 -> v5.4.15
  • symfony/serializer - v5.4.2 -> v5.4.15
  • symfony/stopwatch - v5.4.3 -> v5.4.13
  • symfony/string - v5.4.2 -> v5.4.15
  • symfony/translation - v5.4.2 -> v5.4.14
  • symfony/twig-bridge - v5.4.0 -> v5.4.16
  • symfony/twig-bundle - v5.4.0 -> v5.4.8
  • symfony/uid - v5.4.2 -> v5.4.13
  • symfony/validator - v5.4.2 -> v5.4.15
  • symfony/var-dumper - v5.4.2 -> v5.4.14
  • symfony/var-exporter - v5.4.2 -> v5.4.10
  • symfony/web-link - v5.4.0 -> v5.4.3
  • symfony/web-profiler-bundle - v5.4.6 -> v5.4.14
  • symfony/workflow - v5.4.2 -> v5.4.11
  • symfony/yaml - v5.4.2 -> v5.4.16
  • twig/extra-bundle - v3.3.7 -> v3.5.0
  • twig/twig - v3.3.7 -> v3.5.0
  • xcart/meta-decorator - 5.5.0.x-dev -> 5.5.1.x-dev

Dependency

  • doctrine/cache - 2.1.1 -> 2.2.0
  • doctrine/collections - 1.6.8 -> 1.8.0
  • doctrine/common - 3.2.1 -> 3.4.3
  • doctrine/dbal - 3.2.1 -> 3.5.2
  • doctrine/deprecations - v0.5.3 -> v1.0.0
  • doctrine/event-manager - 1.1.1 -> 1.2.0
  • doctrine/inflector - 2.0.4 -> 2.0.6
  • doctrine/instantiator - 1.4.0 -> 1.4.1
  • doctrine/lexer - 1.2.2 -> 1.2.3
  • doctrine/migrations - 3.3.2 -> 3.5.2
  • doctrine/persistence - 2.3.0 -> 3.1.2
  • doctrine/sql-formatter - 1.1.2 -> 1.1.3
  • friendsofphp/proxy-manager-lts - v1.0.5 -> v1.0.13
  • guzzlehttp/promises - 1.5.1 -> 1.5.2
  • guzzlehttp/psr7 - 1.8.3 -> 2.4.3
  • lcobucci/clock - 2.0.0 -> 2.2.0
  • lcobucci/jwt - 4.1.5 -> 4.2.1
  • monolog/monolog - 2.3.5 -> 2.8.0
  • phenx/php-svg-lib - 0.3.4 -> 0.4.1
  • phpdocumentor/type-resolver - 1.6.0 -> 1.6.2
  • phpstan/phpdoc-parser - 0.4.9 -> 1.15.3
  • psr/link - 1.0.0 -> 1.1.1
  • symfony/cache-contracts - v2.5.0 -> v2.5.2
  • symfony/deprecation-contracts - v2.5.0 -> v3.0.2
  • symfony/event-dispatcher-contracts - v2.5.0 -> v3.0.2
  • symfony/intl - v5.4.3 -> v5.4.15
  • symfony/polyfill-intl-grapheme - v1.24.0 -> v1.27.0
  • symfony/polyfill-intl-icu - v1.24.0 -> v1.27.0
  • symfony/polyfill-intl-normalizer - v1.24.0 -> v1.27.0
  • symfony/polyfill-mbstring - v1.24.0 -> v1.27.0
  • symfony/polyfill-php73 - v1.24.0 -> v1.27.0
  • symfony/polyfill-php80 - v1.25.0 -> v1.27.0
  • symfony/polyfill-php81 - v1.24.0 -> v1.27.0
  • symfony/polyfill-uuid - v1.24.0 -> v1.27.0
  • symfony/service-contracts - v2.5.0 -> v2.5.2
  • symfony/translation-contracts - v2.5.0 -> v2.5.2
  • voku/portable-ascii - 1.5.6 -> 2.0.1
  • webmozart/assert - 1.10.0 -> 1.11.0
  • willdurand/negotiation - 3.0.0 -> 3.1.0

doctrine/orm - 2.10.4 -> 2.14.0

$queryBuilder->iterate()

When using the method $queryBuilder->iterate, it needs to be taken into account that it can return an array or an object. Formerly, it used to always return an array the first element of which was the object in question.

Used to be:

freach ($queryBuilder->iterate() as $result) {
$object = result[0];
...
}

Now:

freach ($queryBuilder->iterate() as $object) {
...
}

Also, it needs to be taken into account that in each case the result depends on the contents of SELECT

$queryBuilder->getSingleResult()

Instead of $queryBuilder->getSingleResult() use $queryBuilder->getQuery()->getSingleResult()

Routing

Now you can use standard symfony mechanisms for routing and creating controllers. This is not yet used everywhere; a complete transition is expected in X-Cart 5.6

To separate controllers into admin controllers and customer controllers, it is necessary to implement the interface \XCart\Controller\Admin\IAdminZone in classes for admin controllers

Security

The format of role codes has been changed to the standard one in symfony: ROLE_*

The codes have been transformed using the following rule:

$code = 'ROLE_' . strtoupper(str_replace([' ', '[', ']'], ['_', '', ''], $code))

Examples

'manage catalog' -> 'ROLE_MANAGE_CATALOG'
'manage admins' -> 'ROLE_MANAGE_ADMINS'
'[vendor] manage catalog' -> 'ROLE_VENDOR_MANAGE_CATALOG'

https://symfony.com/doc/current/security.html#roles

All the necessary changes have been made to the core both in fixtures and in checks, while maintaining backward compatibility.

It has become possible to connect individual rows in the database to a module; it is necessary in order to delete data when removing a module without a separate remove hook.

To use this feature, it is required that the model class should implement the interface \XLite\Model\Base\IModuleRelatedEntity and that the model should have the field model. Should you need to use a different field or a different criterion to determine a connection with a module, the removeByModule method in the model repository can be overriden.

In the core, a connection to modules is provided in the following models:

  • \XLite\Model\AddressField
  • \XLite\Model\Config
  • \XLite\Model\Product\GlobalTab
  • \XLite\Model\Shipping\Method
  • \XLite\Model\Notification
  • \XLite\Model\Role\Permission

For modules, you need to create an appropriate hook to mark the corresponding entries in the database. Similarly, if entries to the specified models are created in the module dynamically, you need to adjust the code so that a mark about the module is added to the entries.

Symfony HttpClient

PEAR2 HTTP Request library has been removed from code; instead of this library it is recommended to use Symfony HttpClient

https://symfony.com/doc/current/http_client.html

Example of changes

Former code:

$request = new \XLite\Core\HTTP\Request($endpoint);
$request->requestTimeout = $this->requestTimeout;
$request->verb = 'POST';
$request->body = ' ';
$request->setHeader('Authorization', 'Basic ' . base64_encode($capostAPIKey->user . ':' . $capostAPIKey->password));
$request->setHeader('Accept', 'application/vnd.cpc.registration+xml');
$request->setHeader('Content-Type', 'application/vnd.cpc.registration+xml');
$request->setHeader('Accept-language', $this->getAcceptLanguage());

if (static::isOnBehalfOfAMerchant()) {
$request->setHeader('Platform-id', $this->getPlatformId());
}

$response = $request->sendRequest();

if (!empty($response->body)) {
$result = $this->parseResponseGetMerchantRegistrationToken($response->body);
}

New code

$options = [
'max_duration' => $this->requestTimeout,
'body' => ' ',
'headers' => [
'Authorization' => 'Basic ' . base64_encode($capostAPIKey->user . ':' . $capostAPIKey->password),
'Accept' => 'application/vnd.cpc.registration+xml',
'Content-Type' => 'application/vnd.cpc.registration+xml',
'Accept-language' => $this->getAcceptLanguage()
]
];

if (static::isOnBehalfOfAMerchant()) {
$options['headers']['Platform-id'] = $this->getPlatformId();
}

$response = \Symfony\Component\HttpClient\HttpClient::create()->request(
'POST',
$endpoint,
$options
);

if (!empty($responseBody)) {
$result = $this->parseResponseGetMerchantRegistrationToken($responseBody);
}

Storefront API

Implemented tools for API development