Skip to content
Snippets Groups Projects

Issue #3483353: EntityDisplayBase::createCopy() naïvely assumes that the...

Open Issue #3483353: EntityDisplayBase::createCopy() naïvely assumes that the...
1 unresolved thread
1 unresolved thread

Issue #3483353: EntityDisplayBase::createCopy() naïvely assumes that the duplicate doesn't already exist

Closes #3483353

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • 325 325 * {@inheritdoc}
    326 326 */
    327 327 #[ActionMethod(adminLabel: new TranslatableMarkup('Copy to another mode'), pluralize: FALSE)]
    328 public function createCopy($mode) {
    329 $display = $this->createDuplicate();
    330 $display->mode = $display->originalMode = $mode;
    328 public function createCopy($mode, bool $use_existing = FALSE) {
    329 $display = NULL;
    330 if ($use_existing) {
    331 // Try first to load the target entity display. If it exists return it.
    332 $display = $this->entityTypeManager()
    333 ->getStorage($this->getEntityTypeId())
    334 ->load($this->getTargetEntityTypeId() . '.' . $this->getTargetBundle() . '.' . $mode);
    • Before the change, the caller can assume it knows the status of the returned display. (If I read things right, it's probably its own status.)

      After the change, the status may be false even when $this->status() is true. (I am guessing that this is realistic, in cases where the caller calls createCopy() on a view mode that "by accident" already exists.) This may not be what the caller expects and I am anxious this is going to lead to bugs.

      Should we update te status to $this->status() always?

      Edited by Roderik Muit
    • That's a really interesting point. The duplicate might exist already and have a different status, which could lead to unexpected behavior.

      I feel like it would be weirder to change the status of the existing one to match the original, but I'm not sure. Maybe the entire approach here needs rethinking; not sure. I feel like I should kick this one up to the framework managers.

    • Please register or sign in to reply
  • added 1 commit

    • 89b92666 - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • added 1 commit

    • d3ddd835 - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • Artem Dmitriiev added 67 commits

    added 67 commits

    • d3ddd835...69df78a3 - 62 commits from branch project:11.x
    • b20a00ac - Issue #3483353: EntityDisplayBase::createCopy() naïvely assumes that the...
    • bba27034 - Add the config from install folder to the test
    • b4a6bc7e - Apply 1 suggestion(s) to 1 file(s)
    • 7cfe50b2 - Apply 1 suggestion(s) to 1 file(s)
    • 80f2f687 - Merge branch '3483353-entity-copy-use-existing' of...

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • Please register or sign in to reply
    Loading