bolt: Bolt 3.6 will break with PHP 7.1.28 and higher

BoltCMS 3.6 will break once people update their PHP version to 7.1.28 because of changes in the intl extension between PHP 7.1.27 and 7.1.28.

Details

Question Answer
Relevant Bolt Version legacy / 3.5 / 3.6 / master
Install type Zip or tar install / Composer install / GitHub checkout
BC Break no
PHP version 7.1
Web server Nginx / CLI
For UX/UI issues not relevant

Reproduction

If you’re filing a bug, please describe how to reproduce it. Include as much relevant information as possible, such as:

Bug summary

The php-intl extension version 7.1.28 returns an empty array when using locale_parse(‘root’) whereas php-intl version 7.1.27 returns an array with the key language and value ‘root’.

We run Ubuntu 18.04 with Ondřej Surý’s PHP repository, which just updated from PHP 7.1.27 to PHP 7.1.28, which causes this issue.

Specifics

Updating php-intl causes a change in the data returned from locale_compose(), which causes Symfony 2.8’s Symfony\Component\Intl\Locale::getFallback(‘root’) to return an empty array. This in turn causes Symfony\Component\Intl\Data\Bundle\Reader::readEntry to never exit the while loop. Finally, this in turn causes Bolt to not load it’s web interface anymore (both frontend and backend) but instead fill up all memory available to PHP , and subsequently exit with an internal server error.

Also composer install when running PHP 7.1.28 will hang until the memory is eaten up and then throw an out of memory exception.

The underlying issue is explained more in-depth here: https://github.com/symfony/symfony/issues/31089

Steps to reproduce

Run the following command on PHP 7.1.27 that has php-intl installed:

$ php -r "var_dump(locale_parse('root'));" See the output is:

Command line code:1:
array(1) {
  'language' =>
  string(4) "root"
}

Now run the same on PHP 7.1.28 with php-intl installed:

$ php -r "var_dump(locale_parse('root'));" See the output is:

Command line code:1:
array(0) {
}

Expected result

I would suspect php-intl does the same thing between patch versions but apparently not…

Actual result

As explained above

The workaround we applied to have a working BoltCMS:

We traced https://github.com/symfony/symfony/issues/31089#issuecomment-482542636 and found the change is not in Location.php as suggested, but in Locale.php: https://github.com/symfony/symfony/pull/30781/files?file-filters[]=.php

We then copied over Symfony’s Locale.php to a different location in our project (we chose src/SymfonyOverrides), applied the patch from the PR above, and added this Locale.php to Composer’s autoload:

        "classmap": [
            "src/SymfonyOverrides"
        ],
        "exclude-from-classmap": [
            "vendor/symfony/intl/Locale.php"
        ],

Update: my colleague @StevendeVries found that we must exclude the original Locale.php to prevent having two classes with the same class name, which is not supported by Composer.

This effectively applies the patch from the PR to Symfony 2.8, so all is good again. However, the real fix would of course be to upgrade to Symfony Flex, which is scheduled for BoltCMS 4.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (10 by maintainers)

Most upvoted comments

We at sulu had the same problem with some old projects so we created this package: https://github.com/sulu/symfony-intl-fix to overwrite the Locale.php.