symphonycms: Error reporting is set too late
Affected Symphony version(s) : 2.7.x PHP version(s) : 7.2 OS(es) : all
Officially Symphony 2.7 is not supported on PHP 7.2. But, given the fact that it’s an LTS release, I nevertheless suggest to keep it working if possible.
PHP 7.2 has an interesting bug. Accoording to the docs, the variant parameter’s default value for the idn_to_utf8 function is INTL_IDNA_VARIANT_2003 — but this value has been deprecated. (No, I am not kidding.) So calling the function without the parameter will raise a deprecation warning. The official bug report can be seen here: https://bugs.php.net/bug.php?id=75609.
If PHP’s default error reporting is set to E_ALL, this PHP bug will cause the deprecation warning to be thrown on every page:
Deprecated: idn_to_utf8(): INTL_IDNA_VARIANT_2003 is deprecated in /var/www/foo/symphony/lib/boot/defines.php on line 218
Why? Symphony sets its own (more forgiving/suppressing) error reporting too late. If you look at index.php, you see:
// Include autoloader:
require_once DOCROOT . '/vendor/autoload.php';
// Include the boot script:
require_once DOCROOT . '/symphony/lib/boot/bundle.php';
Currently Symphony sets the error reporting in bundle.php. But the autoloader will load defines.php before! In this file (line 218) you will see:
define_safe('HTTP_HOST', function_exists('idn_to_utf8') ? idn_to_utf8($http_host) : $http_host);
There are two possible (simple) fixes for this:
- Move the line that defines Symphony’s default error reporting from
bundle.phptoindex.php(before the autoloader). This would mean that Symphony’s error handling is applied to everything that “happens” in the autoloaded files. - Fix only the line that causes the issue, by calling the function like so:
idn_to_utf8($http_host, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46).
@nitriques: I am open to both solutions, and I can send a PR if you tell me which route to take.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 16 (11 by maintainers)
Commits related to this issue
- Prevent warning if PHP's error reporting is E_ALL Re: #2864 — committed to michael-e/symphony-2 by michael-e 6 years ago
- idn_to_utf8: Remove warning if PHP's error reporting is E_ALL (#2868) Fixes #2864 — committed to symphonycms/symphonycms by michael-e 6 years ago
So what do you suggest? Somehting like this?
Thanks!
So the suggested fix is: