When using the Publish Content module alongside the Moderation Sidebar module, clicking the moderation sidebar button on a node page triggers a fatal 500/AJAX error.

This happens because the moderation sidebar renders the local tasks in an off-canvas dialog under its own route:
`/moderation-sidebar/{entity_type}/{entity}/latest`

On this route, the path parameter is named `{entity}` instead of `{node}`. When the local task manager builds the tasks, `PublishContentLocalTask::getTitle()` executes and attempts to load the node using:

$node = $this->nodeStorage->load($this->routeMatch->getRawParameter('node'));

Steps to reproduce

  1. Enable the publishcontent and moderation_sidebar modules.
  2. View a moderated node page and click the "Moderation Sidebar" tab/button.
  3. The sidebar AJAX request fails with a 500 error due to the AssertionError.
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

prem suthar created an issue. See original summary.

prem suthar’s picture

Issue summary: View changes
prem suthar’s picture

Issue summary: View changes
prem suthar’s picture

Issue summary: View changes

gurkawal made their first commit to this issue’s fork.

gurkawal’s picture

Hi @prem suthar

I have created a merge request for this issue.

The fix adds a safe check before loading the node in PublishContentLocalTask::getTitle(). On the Moderation Sidebar route, the route parameter is {entity} instead of {node}, so the previous code tried to load an empty node ID and caused a 500/AJAX error.

Now, if the node route parameter is missing or the node cannot be loaded, it falls back to the parent title. I also updated getCacheTags() to return the node cache tag only when a valid node parameter exists.

This prevents the fatal error and allows the moderation sidebar to open correctly.

Please review once

gurkawal’s picture

Status: Active » Needs review
astonvictor’s picture

Version: 8.x-1.8 » 8.x-1.x-dev
Status: Needs review » Fixed

I'm ok to merge the current MR to the dev version but not sure if the module works with the workflow module - #3023951: Compatible with content moderation?

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.