Issue Bug Closed

#96388Error when replacing polyfill packages in the root composer.json

Simon Gilli 12/19/21, 12:15 updated 05/06/26, 10:51

Description

Symfony recommends to replace the polyfills of installed PHP extensions in the root package to reduce the overhead. Currently when replacing the various polyfill packages an exception is thrown during the autoload dump:

Executing "TYPO3\CMS\Core\Composer\PackageArtifactBuilder":

[UnexpectedValueException]
The package "backend" depends on "symfony/polyfill-mbstring" which is not present in the system.

Exception trace:
 () at /var/www/html/vendor/typo3/cms-core/Classes/Package/PackageManager.php:1116
 TYPO3\CMS\Core\Package\PackageManager->convertConfigurationForGraph() at /var/www/html/vendor/typo3/cms-core/Classes/Package/PackageManager.php:1197
 TYPO3\CMS\Core\Package\PackageManager->buildDependencyGraph() at /var/www/html/vendor/typo3/cms-core/Classes/Package/PackageManager.php:1085
 TYPO3\CMS\Core\Package\PackageManager->sortPackageStatesConfigurationByDependency() at /var/www/html/vendor/typo3/cms-core/Classes/Composer/PackageArtifactBuilder.php:138
 TYPO3\CMS\Core\Composer\PackageArtifactBuilder->sortPackagesAndConfiguration() at /var/www/html/vendor/typo3/cms-core/Classes/Composer/PackageArtifactBuilder.php:103
 TYPO3\CMS\Core\Composer\PackageArtifactBuilder->run() at /var/www/html/vendor/typo3/cms-composer-installers/src/Plugin/Core/ScriptDispatcher.php:72
 TYPO3\CMS\Composer\Plugin\Core\ScriptDispatcher->executeScripts() at /var/www/html/vendor/typo3/cms-composer-installers/src/Plugin/PluginImplementation.php:93
 TYPO3\CMS\Composer\Plugin\PluginImplementation->postAutoloadDump() at /var/www/html/vendor/typo3/cms-composer-installers/src/Installer/Plugin.php:101
 TYPO3\CMS\Composer\Installer\Plugin->listen() at n/a:n/a
 call_user_func() at phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:191
 Composer\EventDispatcher\EventDispatcher->doDispatch() at phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:118
 Composer\EventDispatcher\EventDispatcher->dispatchScript() at phar:///usr/local/bin/composer/src/Composer/Autoload/AutoloadGenerator.php:415
 Composer\Autoload\AutoloadGenerator->dump() at phar:///usr/local/bin/composer/src/Composer/Installer.php:333
 Composer\Installer->run() at phar:///usr/local/bin/composer/src/Composer/Command/UpdateCommand.php:248
 Composer\Command\UpdateCommand->execute() at phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php:245
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:835
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:185
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:327
 Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:117
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:128
 Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:73
 require() at /usr/local/bin/composer:29

There are currently two issues:

1. The replaces are not detected
2. It’s always the backend which is listed in the message even if the backend has not dependency to polyfills at all

Minimal composer.json to reproduce:

{
    "name": "gilbertsoft/test-typo3-11",
    "license": "MIT",
    "description": "Testing TYPO3 11 polyfill issue.",
    "require": {
        "typo3/cms-core": "^11.5",
        "typo3/minimal": "^11.5"
    },
    "provide": {
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-intl-grapheme": "*",
        "symfony/polyfill-intl-icu": "*",
        "symfony/polyfill-intl-idn": "*",
        "symfony/polyfill-intl-normalizer": "*",
        "symfony/polyfill-mbstring": "*",
        "symfony/polyfill-php72": "*",
        "symfony/polyfill-php73": "*"
    }
}

Reviews 6

History 1352

Show 527 earlier messages
  1. Simon Gilli commented and changed status Closed Accepted priority Must have Should have <span data-processor="relativetime" data-value="2021-12-19T23:26:53+00:00" > 12/19/21, 23:26 </span>

    It’s the same behaviour when using replace instead of provide, so a real issue. Here new examples:

    root composer.json

    {
        "repositories": [
          {"type": "path", "url": "packages/*"}
        ],
        "name": "gilbertsoft/test-typo3-11",
        "license": "MIT",
        "description": "Testing TYPO3 11 polyfill issue.",
        "require": {
            "typo3/cms-core": "^11.5",
            "typo3/minimal": "^11.5",
            "gilbertsoft/test-typo3-11-ext": "@dev"
        }
    }

    extension composer.json

    {
        "name": "gilbertsoft/test-typo3-11-ext",
        "type": "typo3-cms-extension",
        "license": "MIT",
        "description": "Testing TYPO3 11 polyfill issue.",
        "replace": {
            "symfony/polyfill-intl-icu": "*"
        },
        "extra": {
            "typo3/cms": {
                "extension-key": "test_typo3_11_ext"
            }
        }
    }
  2. Gerrit Code Review pushed patch set 1 for main to change 72711 status Accepted Under Review <span data-processor="relativetime" data-value="2021-12-20T00:40:08+00:00" > 12/20/21, 00:40 </span>

  1. Helmut Hummel commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-03-24T14:40:09+00:00" > 03/24/26, 14:40 </span>

    Applied in changeset commit:15c263485c474ba9caf13b71588e5391179697c8.

  2. Helmut Hummel commented <span data-processor="relativetime" data-value="2026-05-06T10:51:42+00:00" > 05/06/26, 10:51 </span>

    As a workaround for v13 and lower, create a non TYPO3 extension composer package with the accordant replaces and depend on that in the project.