- Issue created by @cxc891
- πΊπΈUnited States cxc891
Fixed it by lowering the module weight so it runs before the token module.
- π―π΅Japan ultrabob Japan
We could update the install hook and add an update hook to set the module weight to be lower than the token module's if it is installed, but it would be better to figure out the cause. I couldn't immediately identify what would be happening as a result of submitting via workflow buttons as opposed to selecting the target state and saving.
I'm running out of time to look at this today, but it seems like the next step is identifying what is happening on a workflow_buttons submission that would undo the work that token does on save.That is just in case it gives somebody else a jumping-off point for trying to identify the culprit.
@cxc891 did you identify something in particular that lead you to the module weight solution?
- πΊπΈUnited States cxc891
Thanks for looking into it @ultrabob
I started to believe it might be the weight when I set a breakpoint inside the function "token_node_menu_link_submit" in token.module file. The $node object has something strange going on.
$node['#values']['isDefaultRevision']=>["x-default"=>"1"]
however, the"isDefaultRevision()"
method returns false.Inside the same function, a MenuLinkContent entity is created using data from $node. And there is
$entity->isDefaultRevision($node->isDefaultRevision());
before the entity is saved. This takes the "false" value from above and assigns it to the entity, which leads to theMenuLinkContent::postSave
not updating the menu tree.The same issue was causing me a WSOD if I edit a node that's never in a menu and assign it a menu parent. I got something like a "menu plugin not found" error message. Makes sense given my investigation above.
I checked the code from this module too but couldn't find anything that might be a culprit...
- π―π΅Japan ultrabob Japan
workflow_buttons_preprocess_node in workflow_buttons.module is where isDefaultRevision gets set. There is another issue for removing that preprocess π Remove unused preprocess Needs work . It would be interesting to know if removing that preprocess hook would fix this issue.
- πΊπΈUnited States cxc891
Hmm, I thought the preprocess was just to make extra variables avail to the templates. Anyway, the issue is not gone when the function is commented out.
I'm now thinking if it's something inside the
WorkflowButtonsWideget
class. Either theformElement
or theprocessActions
function, whichever is responsible for loading and passing the entity to downstream modules. - πΊπΈUnited States cxc891
I think we need to borrow a line from the content_moderation core module, inside the
formElement
function there is this line to load the most recent revision$original_entity = $this->entityTypeManager->getStorage($entity->getEntityTypeId())->loadRevision($entity->getLoadedRevisionId());
I will test and report.
- π―π΅Japan ultrabob Japan
@cxc891. Do you have anything to report back on this?
- πΊπΈUnited States cxc891
@ultrabob, yes. However, deleting the whole preprocess section does not change anything, nor does the code in #8.
- πΊπΈUnited States ian.ssu
I'm running out of time and want to share findings after spending much of today debugging problem I'm thinking is related to this issue. When adding adding a menu link to an existing Node the following error is throw
Drupal\Core\Entity\EntityStorageException: Plugin ID 'menu_link_content:8a547baa-d9f5-458b-9cc7-939e642f78db' was not found. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 817 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
EntityFormDisplay->extractFormValues->getRenderer
WorkflowButtonsWidget->extractFormValues($items, $form, $form_state) - $entity->isDefaultRevision() stays FALSE
vs
ModerationStateWidget->extractFormValues($items, $form, $form_state) - $entity->isDefaultRevision() changes TRUEIn ModerationStateFieldItemList->updateModeratedEntity (line 167)
$entity->isDefaultRevision($update_default_revision);From my testing it's this Node->isDefaultRevision() FALSE that is causing the issue with menu_link_content postSave
Got to run but I believe there is something different between to WorkflowButtonsWidget and ModerationStateWidget at the heart of this issue.
- Merge request !16Issue #3397027 add WorkflowButtonsWidget::validateElement to correctly set moderation_state β (Merged) created by ian.ssu
- πΊπΈUnited States ian.ssu
I think I found what is happening. The OptionsWidgetBase::validateElement method fails to correctly set the $form_state for moderation_state. This causes issues in ModerationStateFieldItemList->updateModeratedEntity, preventing the detection of moderation state changes. Consequently, this leads to downstream issues with pathauto. I've created MR 16 adding WorkflowButtonsWidget::validateElement.
- Status changed to Needs review
4 months ago 4:57am 19 July 2024 - πΊπΈUnited States cxc891
I can confirm that adding
WorkflowButtonsWidget::validateElement
fixes my issue. I tested it after setting the module weight back to default (0) and everything is working as expected. -
mlncn β
committed 6c26bae5 on 8.x-1.x authored by
ian.ssu β
Issue #3397027: Have to publish twice to update URL alias (pathauto)
-
mlncn β
committed 6c26bae5 on 8.x-1.x authored by
ian.ssu β
- Status changed to RTBC
4 months ago 5:37pm 26 July 2024