Problem/Motivation

I wanted to use this module in Drupal 9 but it throws errors.

PublishContentLocalTask.php Line 63

/** @var \Drupal\node\NodeInterface $node */
    $node = $this->nodeStorage->load($this->routeMatch->getRawParameter('node'));

When I change ot to 'entity' instead of 'node' it works perfectly fine.

Steps to reproduce

Migrate to Drupal 9. Install Moderation Sidebar. Open Moderation Sidebar.

Proposed resolution

Make this module Drupal 9 proof.

Comments

Eugen Zerr created an issue. See original summary.

eugen zerr’s picture

This patch fixes it for me.

admin@azhark.com’s picture

@Eugen
I tried with Drupal 9.3.x, but no error shows.

Can you explain the steps to reproduce in detail so i can replicate.

eugen zerr’s picture

Hi @adminazhar,

sorry for the late reply.
I can't remember why this issue appeared.
However, in D9 you can now get the node entity from the context. You no longer need to use the routematch to get the current node.
See code sample: https://gist.github.com/drubb/28b1cb5389fd33c3746b52ad57c0a0f6
and
https://www.drupal.org/docs/drupal-apis/plugin-api/plugin-contexts

bramdriesen’s picture

Status: Active » Needs review

Setting to NR as there is a patch

rodrigoaguilera’s picture

Status: Needs review » Needs work

Regarding #4
I don't know what is required to be able to get the node from the context in the class that needs to be modified.
Maybe use the trait like blockbase does.
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Plugin%21...

Regarding the patch I think it might still fail as the code is initializing $node to NULL but later is used as $node->isTranslatable()
when it still might be NULL.