Module does not work with VBO 4.2.3 and Drupal 9.5

Created on 26 February 2023, over 1 year ago
Updated 30 April 2024, 7 months ago

Problem/Motivation

With the VBO 4.2.3 and Drupal 9.5 the VBO add to cart throws the following error:Error: Call to a member function isAllowed() on bool in Drupal\views_bulk_operations\Service\ViewsBulkOperationsActionProcessor->process() (line 447 of .../web/modules/contrib/views_bulk_operations/src/Service/ViewsBulkOperationsActionProcessor.php)

Steps to reproduce

1. Add a commerce product type view
2. Select the VBO add to cart option
3. The view will throw the error code above

Proposed resolution

There are actually three different interrelated errors that need to be dealt with:

1. The first error (mentioned above) is related to this issue: https://www.drupal.org/project/views_bulk_operations/issues/3283085 🐛 Error on batch update or delete - Call to a member function isAllowed() on bool Fixed . I cannot judge whether this can be dealt with within this module (instead of VBO itself).

2. After applying the suggested patch (#8 from issue 3283085), another error is shown: Error: Call to undefined method Drupal::entityManager() in Drupal\vbo_add_to_cart\Plugin\Action\ViewsBulkAddToCartAction->execute() (line 73 of /.../web/modules/contrib/vbo_add_to_cart/src/Plugin/Action/ViewsBulkAddToCartAction.php). This appears to be related to a Drupal core update, and is dealt with in https://www.drupal.org/project/vbo_add_to_cart/issues/3299414 📌 Automated Drupal 10 compatibility fixes RTBC .

3. After applying the automated patch suggested by the Project Update Bot, the Add to cart bulk operation is executed, but a third error message is shown: Error: Object of class Drupal\Core\Messenger\Messenger could not be converted to string in Drupal\views_bulk_operations\Service\ViewsBulkOperationsActionProcessor->process() (line 502 of /.../modules/contrib/views_bulk_operations/src/Service/ViewsBulkOperationsActionProcessor.php)

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇮🇪Ireland marksmith

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Issue created by @marksmith
  • Assigned to druprad
  • Status changed to Needs work 9 months ago
  • 🇮🇪Ireland marksmith

    Unfortunately, the new 3.0.1 version did not solve the problems above. There remain two lines of code that need to be altered in order to work correctly:

    Firstly,
    $entity_manager = \Drupal::entityManager();
    needs to be changed into:
    $entity_manager = \Drupal::service('entity_type.manager');

    Secondly, this line:
    return \Drupal::messenger()->addMessage($this->t('Items are added to cart successfully.'), 'status');
    needs to be changed into:
    \Drupal::messenger()->addMessage($this->t('Items are added to cart successfully.'), 'status');

    Moreover, I am wondering whether issue https://www.drupal.org/project/views_bulk_operations/issues/3283085 🐛 Error on batch update or delete - Call to a member function isAllowed() on bool Fixed needs to be dealt with within vbo_add_to_cart rather than views_bulk_operations.

  • Status changed to Fixed 7 months ago
  • 🇸🇬Singapore druprad

    Code corrected in 3.0.2 release

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

Production build 0.71.5 2024