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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vdanielpop created an issue. See original summary.

vdanielpop’s picture

Issue summary: View changes
zerolab’s picture

Status: Active » Needs review
FileSize
1 KB

Attaching a patch fixing the null coalesce operator (??), as ?: was added in PHP 5.3 and has been long supported.

lucastockmann’s picture

Status: Needs review » Reviewed & tested by the community

Patch applies and works fine.

RTBC

kyberman’s picture

Priority: Normal » Major

Thanks zerolab for patch, tested it works.
Increasing priority, because problem breaks installation process.

  • itsekhmistro committed 1eecf69 on 8.x-1.x authored by zerolab
    Issue #2830543 by zerolab: Replace PHP7-only operators with their older...
itsekhmistro’s picture

Status: Reviewed & tested by the community » Fixed

Thanks everyone involved.

The Patch is applied.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.