Problem/Motivation
When running 'drush csim -y' drush crashes with a PHP syntax error:
ParseError: syntax error, unexpected 'EntityTypeRepositoryInterface' ( T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in Composer\Autolo ad\includeFile() (line 40 of /home/strcom/public_test/releases/dev-master-111/we b/modules/contrib/dynamic_entity_reference/src/Plugin/Field/FieldWidget/DynamicE ntityReferenceWidget.php)
I found this out to be because two classes declare properties with the optional type introduced in PHP7.4.
Steps to reproduce
Run the above command on a Drupal 9 site with PHP 7.3 and this module
Proposed resolution
There are two options:
1. Mark this module as only compatible with PHP 7.4+
2. Change the two classes to remove the type in the property declarations
I am in favour of option 2 and supply a patch for this. I am in favour of this because of incompatibility that I have found between PHP 7.4 and twig requiring twig v1.43.0+ or v2.10.0+ which was an issue for me (I forget why) and because this feature of PHP7.4 has not been used elsewhere in this module.
Remaining tasks
Decide on solution and implement
User interface changes
None
API changes
None
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| php-7.3-compatability-fix.patch | 1.79 KB | rory downes |
Comments
Comment #2
jibranOption 2 is not the way to go here especially after #3246916: Drop D8, D9.2, and PHP 7.3 support. Can I please have a patch for option 1?
If you want PHP 7.3 support please use 8.x-2.0-alpha15.
Comment #3
rory downes commentedThanks for your feedback jibran and your recommendations.
The patch on ticket https://www.drupal.org/project/dynamic_entity_reference/issues/3246916 works for option 1.
However, no patch will work for this until committed and a new release created as changes to composer.json have to be in the release to have an impact.
Regards Rory
Comment #4
jibranComment #7
jibranPushed a fix to both 1.x and 2.x branches. Will create a new release in a bit.
Comment #8
dpiComment #9
faesch@gmx.de commentedThis now broke my update.php due to incompatibility to PHP 7.3 (which I'm using).
I just checked and composer.json still requires >= 7.3.
Forcing version 1.13 in composer so I can run updates as I can't switch to PHP 7.4.
Comment #10
rory downes commentedm-p-j - note in comment #2 that jibran says 8.x-2.0-alpha15 also supports PHP7.3 - just in case that is useful to you.
Regards Rory
Comment #11
sam452 commentedcomposer require 'drupal/dynamic_entity_reference:^2.0@alpha' returns the latest alpha which enforces PHP 7.4. Thankfully alpha15 is available. My Composer fu is small. How should I craft my composer call to get this specific alpha?
Comment #12
rory downes commentedsam452 change the '^2.0@alpha' to '2.0.0-alpha15' should constrain your project to alpha15.
Regards Rory
Comment #13
jibranSorry folks, I'll try to create a new release later this week with the proper fix.
Comment #16
jibranVersion number is fixed in
composer.jsonand all sub-modules.Comment #18
nojj commentedJust tried to install Version 1.16. Previous installed 1.13.
Getting:
Package drupal/dynamic_entity_reference at version ^1.16 has requirements incompatible with your PHP version, PHP extensions
and Composer version:
- drupal/dynamic_entity_reference 1.16.0 requires php >=7.4 which does not match your installed version 7.3.33.
I switched to PHP 7.4 before and in Drupal status information PHP 7.4.2 is shown.
Any tipps to solve this?
thanks in advance
Comment #19
jibranMaybe try with
composer installwith--ignore-platform-reqsoption.Comment #20
nojj commentedseems a little bit risky. (never done that)
Strange thing: I have a local copy of that Drupal installation, and there I don't get that error, when running PHP 7.4.
maybe I can look somewhere else ?