Problem/Motivation

Get error when doing a batch update:

Error: Call to undefined method Drupal\Core\StringTranslation\TranslatableMarkup::isAllowed() in Drupal\views_bulk_operations\Service\ViewsBulkOperationsActionProcessor->process() (line 461 of /Users/lluisandreu/Projects/drupal/felibcursos/web/modules/contrib/views_bulk_operations/src/Service/ViewsBulkOperationsActionProcessor.php).

Steps to reproduce

Using php 8.0 and Drupal last core version.

Comments

lluisandreu created an issue. See original summary.

graber’s picture

Status: Active » Postponed (maintainer needs more info)

Steps to reproduce incomplete.

redzeuf’s picture

It seems I have the same error and it seems to been introduced in the VBO version 4.1.2, on my side it come from the check access in \src\Service\ViewsBulkOperationsActionProcessor.php:462

It does not seems to be relative to the class TranslatableMarkup but more by the service ViewsBulkOperationsActionProcessor.php->process()

Old code was:

if (!$this->action->access($entity, $this->currentUser)) {
        $output[] = $this->t('Access denied');
        unset($this->queue[$delta]);}

The new code:

 $accessResult = $this->action->access($entity, $this->currentUser, TRUE);
      if ($accessResult->isAllowed() === FALSE) {
        $message = $this->t('Access denied');

        // If we're given a reason why access was denied, display it.
        if ($accessResult instanceof AccessResultReasonInterface) {
          $reason = $accessResult->getReason();
          if (!empty($reason)) {
            $message = $this->t('Access denied: @reason', [
              '@reason' => $accessResult->getReason(),
            ]);
          }
        }

        $output[] = $message;

When I revert this change to the old code, it works again.

My full error message is:
Error: Call to a member function isAllowed() on bool in Drupal\views_bulk_operations\Service\ViewsBulkOperationsActionProcessor->process() (line 464 of /var/www/html/docroot/modules/contrib/views_bulk_operations/src/Service/ViewsBulkOperationsActionProcessor.php)

It appends when I try to delete a file from /admin/content/files either my ownership files not only ones from other users. Precisino, I'm with the super admin user.

redzeuf’s picture

Status: Postponed (maintainer needs more info) » Active
redzeuf’s picture

Title: undefined method Drupal\Core\StringTranslation\TranslatableMarkup::isAllowed() i » Error on batch update or delete - Call to a member function isAllowed() on bool

Updated the issue title

redzeuf’s picture

StatusFileSize
new853 bytes

Patch proposition to review the permission condition that seems to always be false and by the way killed the batch process.

redzeuf’s picture

Status: Active » Needs review
redzeuf’s picture

StatusFileSize
new756 bytes

Fixed previous patch that I submitted and that was not applicable due to path error

graber’s picture

Status: Needs review » Closed (duplicate)

It's a duplicate. No time to search for the same issue though, maybe someone can link it.

redzeuf’s picture

Added to related issues that seems to be the similares (duplicate) to this one.

graber’s picture

Yes, thank you. So you have to update your actions to return AccessResult according to parent interface @return doc info and not bool only, this'll not be fixed.

kimble’s picture

I ran into a need for this patch in 4.1.4 and it worked fine but then 4.1.5 was released just a few days ago and the lines targeted by this patch change so patch no longer works. This fix is not in 4.1.5 release.

lluisandreu’s picture

I am facing the same issue on version 4.20. Please we need a fix as this is a major bug.

redzeuf’s picture

Status: Closed (duplicate) » Fixed

Appologize my patch was false, I miss used the access result interface. This permission access is not a responsability of VBO. You can find information and fix on this issue https://www.drupal.org/project/drupal/issues/2949017#comment-14899806

The issue has been fixed and included since Drupal 10.1

Status: Fixed » Closed (fixed)

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