Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal Error when StringWrapper/Intl:strlen is passed null (BC break in 3.4.0) #29

Closed
ittmann opened this issue Jul 5, 2021 · 5 comments
Assignees
Labels
Bug Something isn't working Duplicate This issue or pull request already exists Invalid This doesn't seem right

Comments

@ittmann
Copy link

ittmann commented Jul 5, 2021

In 3.4.0 (because/after declare(strict_types=1) was added) when null is passed to StringWrapper/Intl:strlen a Fatal Error is thrown.
This was not the case in previous versions (up to 3.3.1)

PHP Fatal error: Uncaught TypeError: grapheme_strlen() expects parameter 1 to be string, null given in /application/vendor/laminas/laminas-stdlib/src/StringWrapper/Intl.php:55

For example (in our case) it is triggered in an application using laminas-mvc-console when php public/index.php is run without arguments (this normally displays usage information)

PHP Fatal error:  Uncaught TypeError: grapheme_strlen() expects parameter 1 to be string, null given in /application/vendor/laminas/laminas-stdlib/src/StringWrapper/Intl.php:55
Stack trace:
#0 /application/vendor/laminas/laminas-stdlib/src/StringWrapper/Intl.php(55): grapheme_strlen(NULL)
#1 /application/vendor/laminas/laminas-mvc-console/src/View/RouteNotFoundStrategy.php(397): Laminas\Stdlib\StringWrapper\Intl->strlen(NULL)
#2 /application/vendor/laminas/laminas-mvc-console/src/View/RouteNotFoundStrategy.php(344): Laminas\Mvc\Console\View\RouteNotFoundStrategy->renderTable(Array, 3, 237)
#3 /application/vendor/laminas/laminas-mvc-console/src/View/RouteNotFoundStrategy.php(153): Laminas\Mvc\Console\View\RouteNotFoundStrategy->getConsoleUsage(Object(Laminas\Console\Adapter\Posix), 'index.php', Object(Laminas\ModuleManager\ModuleManager))
#4 /application/vendor/laminas/laminas-eventmanager/src/EventManager.php(331): Laminas\Mvc\Console\View\RouteNotFoundStrategy->handleRouteNotFoundError(Object(Laminas\Mvc\MvcEvent))
#5 /applic in /application/vendor/laminas/laminas-stdlib/src/StringWrapper/Intl.php on line 55
@Ocramius
Copy link
Member

Ocramius commented Jul 5, 2021 via email

@ittmann
Copy link
Author

ittmann commented Jul 5, 2021

These operations require string input as per API signature?

grapheme_strlen does, but StringWrapper/Intl:strlen didn't before / without the strict_types it didn't throw an error

@Ocramius
Copy link
Member

Ocramius commented Jul 5, 2021 via email

@ittmann
Copy link
Author

ittmann commented Jul 5, 2021

It always did

yes, but without the declare(strict_types=1) introduced in 3.4.0 grapheme_strlen(null) returns (int) 0

@Ocramius
Copy link
Member

Ocramius commented Jul 5, 2021

Closing as duplicate of laminas/laminas-escaper#20

@Ocramius Ocramius closed this as completed Jul 5, 2021
@Ocramius Ocramius self-assigned this Jul 5, 2021
@Ocramius Ocramius added Bug Something isn't working Invalid This doesn't seem right Duplicate This issue or pull request already exists labels Jul 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Duplicate This issue or pull request already exists Invalid This doesn't seem right
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants