#41562 closed task (blessed) (fixed)
PHP 7.2: create_function deprecation in \Gettext_Translations class
Reported by: | ayeshrajans | Owned by: | pento |
---|---|---|---|
Milestone: | 4.9 | Priority: | normal |
Severity: | normal | Version: | |
Component: | I18N | Keywords: | needs-patch |
Focuses: | Cc: |
Description
Please see #37082 for the complement issue, and #40109 for the parent issue.
Please see Sara's (who is one of the leading contributors to PHP 7.2) ticket #37082 for information. Her patches fixed majority of the erros for create_function()
.
I tried a new approach, similar to how Closure
class works in modern PHP versions.
\Gettext_Translations::make_plural_form_function
function returns a callable, which can also be in the form of [$object, 'method']
. Please review this new approach with the \TranslationMultipleFormCallback
class. It still calls eval()
because there is no other way to evaluate nplural formulas without a comprehensive parser.
create_function()
is no better than eval()
because it is merely a thin wrapper around eval()
.
With the patch in #41457 applied, there is only 1 PHP error in Travis CI PHP 7.2 builds! : https://travis-ci.org/Ayesh/wordpress-develop/jobs/261036177#L1257
Attachments (1)
Change History (11)
#2
@
3 years ago
- Milestone changed from Awaiting Review to 4.9
- Owner set to rmccue
- Status changed from new to assigned
- Type changed from defect (bug) to task (blessed)
#3
@
3 years ago
Thanks @johnbillion.
I tried to find a way to evaluate the n-plural formulas too (no eval()
), without much success. I have, however, worked on a little parser to evaluate them. I'll try to see if I can put together.
#4
@
3 years ago
Here is Drupal implementation: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Component%21Gettext%21PoHeader.php/class/PoHeader/8.2.x
Drupal 7 had eval()
, but replaced in 8.x.
#7
@
2 years ago
- Keywords needs-patch added; has-patch removed
- Resolution fixed deleted
- Status changed from closed to reopened
This breaks the internet on PHP 5.2 and 5.3. https://travis-ci.org/WordPress/wordpress-develop/builds/283011249
Thanks for the patch, @ayeshrajans.
As you noted,
eval()
is no better thancreate_function()
, although it does get rid of the deprecated notice that's shown in PHP 7.2.@rmccue has been working on a comprehensive solution for this for a while, which avoids using
create_function()
oreval()
. I'll ask him to upload his patch here along with all the information, research, and testing that he's done.