Skip to content

[Polyfill] mbstring polyfill does not have its iconv dependency declared #52207

Closed
@theofidry

Description

@theofidry

Symfony version(s) affected

All versions of symfony/polyfill-mbstring

Description

From the description of Mbstring:

Partial mbstring implementation in PHP, iconv based, UTF-8 centric.

And indeed the class uses a few ext-iconv functions, for instance: https://github.com/symfony/polyfill-mbstring/blob/1.x/Mbstring.php#L116

The package is quite old (~8yo) so I do not know if this was a conscious decision at that time, a lack of support from Composer or if this is actually wanted. But my understanding is that the package currently depends on ext-iconv but does not declare it. As a result you can end up with the following failure:

Uncaught Error: Call to undefined function Symfony\Po  
  lyfill\Mbstring\iconv_substr() in /path/to/project/vendor/symfony/  
  polyfill-mbstring/Mbstring.php:660

How to reproduce

I did not try to reproduce it on its own as I think the issue is understandable enough. But I think currently this can be done by:

  • having an project using GitHub Actions with a ubuntu-latest image
  • using the PHP binary coming with the image
  • having the project using symfony/polyfill-mbstring and using the mb_substr() function

I encountered this issue while debugging something entirely unrelated in https://github.com/box-project/box/actions/runs/6591562359/job/17910413036?pr=1089.

Possible Solution

Add ext-iconv to the require of the composer.json

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions