Problem/Motivation

In DraggableListBuilderTrait:

  protected $weightKey = FALSE;

If a using class tries to do:

  protected $weightKey = 'weight';

then you get this crash:

> Fatal error: Drupal\finders_facets\Entity\Handler\FindersFacetListBuilder and Drupal\Core\Entity\DraggableListBuilderTrait define the same property ($weightKey) in the composition of Drupal\finders_facets\Entity\Handler\FindersFacetListBuilder. However, the definition differs and is considered incompatible. Class was composed in /var/www/html/repos/finders/modules/finders_facets/src/Entity/Handler/FindersFacetListBuilder.php on line 12

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3590729

Command icon 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

joachim created an issue. See original summary.

joachim’s picture

I was thinking it was because of the type changing, but it's not even that, it's just the differing value -- this crashes too:

<?php
trait MyTrait {
  protected $prop = '';
}

class UsesTrait {
  use MyTrait;
  protected $prop = 'foo';
}

ishani patel made their first commit to this issue’s fork.

ishani patel’s picture

Hello @joachim,
I've raised MR.
Could you please review it.

Thank you!

nitinkumar_7’s picture

Status: Active » Needs work

Replacing the property with getWeightKey() is the right approach.
A few things to fix before this is ready:
1. Remove $weightKey from the trait entirely. If the property stays, the original crash still happens for classes using the trait directly.
2. Check for remaining $this->weightKey references with grep -rn 'weightKey' core/ — any direct property reads left behind will cause "undefined property" errors once the property is removed.
3. Investigate the failing tests.