There are several places where a required function parameter follows a parameter with a default value. This raises a deprecation notice in PHP 8.0. These can be fixed by removing the default values preceding parameters without them.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | entity-n3206793-7.patch | 4.07 KB | damienmckenna |
| #5 | entity-n3206793-5.patch | 3.09 KB | damienmckenna |
Issue fork entity-3206793
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
damienmckennaRunning tests on Metatag results in the following:
Comment #3
damienmckennaComment #4
damienmckennaThe same errors also occur with the Date module.
Comment #5
damienmckennaA possible solution.
Comment #6
liam morlandThanks for the patch.
The change to entity_metadata_system_get_page_properties() adds an
arraytype declaration. That parameter it not actually used, so this function could be called without an array. I recommend leaving it to a separate issue to add type declarations.Some of the changes add a default value to currently-required parameters instead of removing the defaults. This is probably harmless, but also probably useless. Any current calls to the function need to provide all the parameters anyway. Unless there is a clear use case for these functions with more optional parameters, I recommend fixing the issue by removing the default values.
Comment #7
damienmckennaSo something more like this?
Comment #8
liam morlandNo change is needed to entity_metadata_user_access() and entity_metadata_taxonomy_access(). The others looks fine. There is nothing wrong with having default values. There just can't be default values on parameters that precede a parameter without a default.
Comment #9
liam morlandComment #10
tr commentedThe same errors affect Rules. They will affect ALL modules that have Entity API as a dependency, but Rules is one of the big ones.
Because Entity API is used on about 70% of all Drupal sites according to the usage statistics, Drupal can't really claim to be "PHP 8.0 compatible" until Entity API and a few other essential modules are made to work with PHP 8.0.
Bumping priority to "Major" because this affects so many sites.
Comment #12
liam morlandCreated merge request with the patch in #7 minus the changes to entity_metadata_user_access() and entity_metadata_taxonomy_access().
Comment #13
tr commentedThis fixes the problems in a backwards-compatible way. And it's a surprisingly small patch that will have a big impact.
Comment #15
tr commentedMerged. Thanks. I plan to release a new 7.x-1.10 branch including this fix, but I first need to triage the issue queue and determine what other small fixes should be included. As 7.x-1.x is going to be minimally maintained until D7 EOL, I don't anticipate including any new features or any potentially disruptive changes at all.
Comment #17
joseph.olstad@TR, great work and thanks very much in advance! We might as well tag and release? This will greatly assist the move to support php 8.0
Comment #18
tr commented@joseph.olstad: I opened an issue for the new release: #3221001: Plan for release of 7.x-1.10
If you can, please go through the issue queue and help me identify some issues that can be committed and/or finished off quickly so we can get them into the new release. Post your findings in #3221001: Plan for release of 7.x-1.10, and hopefully I can get those committed and the release made within the next few weeks.
Comment #19
tr commentedThis patch missed fixing the functions in entity.features.inc. See #3222090: Remove required parameter following optional parameter in entity.features.inc (PHP 8.0) for a follow-up issue.
entity.features.inc was missed because it is not used by the Entity API tests, so testing against PHP 8.0 did not reveal the problems.