Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
There are a few places in code where coalescence operators are used.
ConditionalFieldEditForm.php, line 332
$selected_state = $form_state->getValue('state') ?: $condition['settings']['state'];
ConditionalFieldEditForm.php, line 190
'#default_value' => $settings['regex'] ?? '',
We have to take into consideration the fact that PHP-7 is not mandatory for D8 installs.
This syntax is not valid on older versions of PHP and will throw a Syntax error.
Proposed resolution
Replace the mentioned operators with their older counter-parts, according to: https://secure.php.net/manual/en/migration70.new-features.php
Comment | File | Size | Author |
---|---|---|---|
#3 | conditional_fields-replace-php7-only-operators-2830543-3.patch | 1 KB | zerolab |
Comments
Comment #2
vdanielpop CreditAttribution: vdanielpop as a volunteer and at PitechPlus commentedComment #3
zerolab CreditAttribution: zerolab at Torchbox for The Chartered Society of Physiotherapy commentedAttaching a patch fixing the null coalesce operator (??), as
?:
was added in PHP 5.3 and has been long supported.Comment #4
lucastockmann CreditAttribution: lucastockmann at undpaul commentedPatch applies and works fine.
RTBC
Comment #5
kybermanThanks zerolab for patch, tested it works.
Increasing priority, because problem breaks installation process.
Comment #7
itsekhmistro CreditAttribution: itsekhmistro at Adyax commentedThanks everyone involved.
The Patch is applied.