Issue #3483353: EntityDisplayBase::createCopy() naïvely assumes that the...
Merge request reports
Activity
added 1 commit
- bb964fbc - Add the config from install folder to the test
- Resolved by Artem Dmitriiev
- Resolved by Artem Dmitriiev
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 MuitThat'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.
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...
Toggle commit list-
d3ddd835...69df78a3 - 62 commits from branch