- Issue created by @tahiche
"You are not authorized to access this page." when accessing a translation layout when the original layout has not been edited/saved.
- create some content in english (original language). save
- create translation (spanish). save
- Access layout tab in spanish translation.
- You get permission access denied.
The issue seems to be in handleTranslationAccess() (layout_builder_st/src/Plugin/SectionStorage/OverridesSectionStorage.php) function.
Specifically the "$this->isOverridden()" check which is false on content where original layout has not been saved.
isOverriden() function is from core layout_builder:
public function isOverridden() {
// If there are any sections at all, including a blank one, this section
// storage has been overridden. Do not use count() as it does not include
// blank sections.
return !empty($this->getSections());
}
When original content hasn´t been saved "$this->getSections()" is empty array.
Just saving the original empty layout, without adding any content makes getSections() an array with one entry "\Drupal\layout_builder\Section", and thus passes the access check.
Seeems like simply removing the isOverridden() check in handleTranslationAccess() solves the issue, but might have unwanted effects.
If the original content layout indeed needs to be edited/saved first, at least there should be some message/warning as the "You are not authorized to access this page." message is extremely confusing as it´s got nothing to do with actual permissions.
Active
Code