I added a new Field to a Content Type and as soon I try to edit it, I will get the following error:

PHP Fatal error: Declaration of Drupal\\Core\\TypedData\\ComputedItemListTrait::getValue() must be compatible with Drupal\\Core\\Field\\FieldItemList::getValue($include_computed = false) in /home/Projekte/php/web/core/modules/path/src/Plugin/Field/FieldType/PathFieldItemList.php on line 13

Comments

JR Tera3yte created an issue. See original summary.

cilefen’s picture

Priority: Normal » Major
Issue tags: -PHP7.2 +PHP 7.2

The only change is moving to PHP 7.2?

cilefen’s picture

Is this a duplicate?

amateescu’s picture

Status: Active » Closed (duplicate)

Yup, it is.

cburschka’s picture

See https://www.drupal.org/project/drupal/issues/2923015

PHP 7.2.0 enforces some type checks that it used to ignore previously, so Drupal does not run in PHP 7.2+. (See https://www.drupal.org/docs/8/system-requirements/php)

(It's possible this may not be fixed in a patch release in 8.4.x, which would mean Drupal won't support PHP 7.2.0 until 8.5.0.)

remyyyyy’s picture

To fix the issue in drupal 8.4.x add this function on top of the class PathFieldItemList just after the line 15 into the file core/modules/path/src/Plugin/Field/FieldType/PathFieldItemList.php

         /**
	 * {@inheritdoc}
	 * @todo Revisit the need when all entity types are converted to NG entities.
	 */
	public function getValue($include_computed = FALSE) {
	  $values = [];
	  foreach ($this->list as $delta => $item) {
	    $values[$delta] = $item->getValue($include_computed);
	  }
	  return $values;
	}