Problem/Motivation

The issue was already reported in: https://www.drupal.org/i/3378586

That issue was resolved as fixed, but I can still reproduce the error (and others, not mentioned in the original issue). I believe I configured everything as described in the README. Also, even if it would be caused by misconfiguration, producing errors is not ideal.

The root cause seems to be, that when any of the action plugins try to retrieve the value for the current_translation_only config value during execution, the plugin configuration is not always set. This produces type errors (and undefined array key warnings). I'm writing 'not always set', because it is not set for me as I was testing the issue, although it is possible to configure each action in the Action UI and save the configuration for them. Also, I'm not sure why it's not the case, but I think it should also be possible to configure this as a step when applying these actions, but this configuration during application never happens.

Nevertheless, just by following the readme and trying to apply the actions, all of them produces the errors (listing them per action class):

DraftCurrentRevisionAction

TypeError: Drupal\moderated_content_bulk_publish\AdminModeratedContent::draft(): Argument #1 ($currentTranslationOnly) must be of type bool, null given, called in /var/www/html/src/Plugin/Action/DraftCurrentRevisionAction.php on line 43 in Drupal\moderated_content_bulk_publish\AdminModeratedContent->draft() (line 154 of /var/www/html/src/AdminModeratedContent.php).

Drupal\moderated_content_bulk_publish\Plugin\Action\DraftCurrentRevisionAction->execute() (Line: 67)
...
Warning: Undefined array key "current_translation_only" in Drupal\moderated_content_bulk_publish\Plugin\Action\DraftCurrentRevisionAction->execute() (line 42 of /var/www/html/src/Plugin/Action/DraftCurrentRevisionAction.php).

PinContentAction

TypeError: Drupal\moderated_content_bulk_publish\AdminHelper::getAllLanguagesToUpdate(): Argument #2 ($currentTranslationOnly) must be of type bool, null given, called in /var/www/html/src/AdminPin.php on line 160 in Drupal\moderated_content_bulk_publish\AdminHelper->getAllLanguagesToUpdate() (line 115 of /var/www/html/src/AdminHelper.php).
Drupal\moderated_content_bulk_publish\AdminPin->pin() (Line: 41)

Drupal\moderated_content_bulk_publish\Plugin\Action\PinContentAction->execute() (Line: 67)
...
Warning: Undefined array key "current_translation_only" in Drupal\moderated_content_bulk_publish\Plugin\Action\PinContentAction->execute() (line 40 of /var/www/html/src/Plugin/Action/PinContentAction.php).

PublishLatestRevisionAction

TypeError: Drupal\moderated_content_bulk_publish\AdminModeratedContent::publish(): Argument #5 ($currentTranslationOnly) must be of type bool, null given, called in /var/www/html/src/Plugin/Action/PublishLatestRevisionAction.php on line 44 in Drupal\moderated_content_bulk_publish\AdminModeratedContent->publish() (line 212 of /var/www/html/src/AdminModeratedContent.php).

Drupal\moderated_content_bulk_publish\Plugin\Action\PublishLatestRevisionAction->execute() (Line: 67)
...
Warning: Undefined array key "current_translation_only" in Drupal\moderated_content_bulk_publish\Plugin\Action\PublishLatestRevisionAction->execute() (line 43 of /var/www/html/src/Plugin/Action/PublishLatestRevisionAction.php).

UnpinContentAction

TypeError: Drupal\moderated_content_bulk_publish\AdminHelper::getAllLanguagesToUpdate(): Argument #2 ($currentTranslationOnly) must be of type bool, null given, called in /var/www/html/src/AdminPin.php on line 117 in Drupal\moderated_content_bulk_publish\AdminHelper->getAllLanguagesToUpdate() (line 115 of /var/www/html/src/AdminHelper.php).

Drupal\moderated_content_bulk_publish\AdminPin->unpin() (Line: 41)
Drupal\moderated_content_bulk_publish\Plugin\Action\UnpinContentAction->execute() (Line: 67)
...
Warning: Undefined array key "current_translation_only" in Drupal\moderated_content_bulk_publish\Plugin\Action\UnpinContentAction->execute() (line 40 of /var/www/html/src/Plugin/Action/UnpinContentAction.php).

UnpublishCurrentRevisionAction

TypeError: Drupal\moderated_content_bulk_publish\AdminModeratedContent::unpublish(): Argument #3 ($currentTranslationOnly) must be of type bool, null given, called in /var/www/html/src/Plugin/Action/UnpublishCurrentRevisionAction.php on line 44 in Drupal\moderated_content_bulk_publish\AdminModeratedContent->unpublish() (line 271 of /var/www/html/src/AdminModeratedContent.php).

Drupal\moderated_content_bulk_publish\Plugin\Action\UnpublishCurrentRevisionAction->execute() (Line: 67)
...
Warning: Undefined array key "current_translation_only" in Drupal\moderated_content_bulk_publish\Plugin\Action\UnpinContentAction->execute() (line 43of /var/www/html/src/Plugin/Action/UnpublishCurrentRevisionAction.php).

Besides the above, the two other action plugins not listed AssignOwnerModeratedNode and SaveModeratedNodeAction also uses this config similarly, so I assume has the same issue. As these actions are not available in the Content admin view currently, I didn't test them specifically.

Steps to reproduce

I tested this on Drupal 11.2.5 with latest module version 3.0.0-beta21, but could also reproduce on Drupal 10.5 with 3.0.0-beta20. My tests were done on a clean install using ddev.

I used standard profile, with the default Editorial workflow and default content types (Article, Basic page). Both enabled for the workflow.

I visited the module settings page and saved the configuration there: /admin/config/content/moderated-content-bulk-publish

Using these pre-requisites, I couldn't use any of the bulk actions on the nodes I created because of the errors listed above.

Proposed resolution

I think that avoiding the possibility of those errors and making sure that only boolean value is passed in those places is something that definitely should be done.

But going further, I think that the ideal would be, if the value saved in the global module config for current_translation_only would be used as a fallback, if the plugin config is not available for some reason.

Maybe I'm wrong and the reason why the plugin config is not available should be investigated instead. I'd like to hear the opinion of the maintainers about this.

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#2 3551010-2.patch6.78 KBkeszthelyi

Comments

keszthelyi created an issue. See original summary.

keszthelyi’s picture

StatusFileSize
new6.78 KB

Attaching a patch that I think would solve this issue. If the maintainers agree with the approach, I'd be glad to open an MR.

  • joseph.olstad committed 3b1e31d3 on 3.0.x
    [#3551010] feat: Errors when current_translation_only plugin config...
joseph.olstad’s picture

Status: Active » Fixed

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

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

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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