A custom plugin "does not exist" during a schema update

Created on 16 January 2023, over 1 year ago
Updated 14 July 2023, about 1 year ago

Hey people, I am experiencing this issue on one project, I have written a custom Action Plugin and when trying to install it through module, I get this error message always:

This is the Action code:

/**
 * Implements hook_update_N().
 *
 * Add the system action for unlocking carts.
 */
function destilatorshop_cart_cleanup_update_9011() {
  $actions = \Drupal::entityTypeManager()->getStorage('action')->loadByProperties(['id' => 'unlock_cart']);
  if (empty($actions)) {
    $action = Action::create([
      'id' => 'unlock_cart',
      'label' => 'Unlock Cart',
      'type' => 'commerce_order',
      'plugin' => 'unlock_cart',
    ]);
    $action->trustData()->save();
  }
}

This is the Action Plugin:


use Drupal\Core\Action\ActionBase;
use Drupal\Core\Session\AccountInterface;

/**
 * Action for unlocking the cart.
 *
 * @Action(
 *   id = "unlock_cart",
 *   label = @Translation("Unlock cart"),
 *   type = "commrece_order",
 *   confirm = TRUE,
 *   requirements = {
 *     "_permission" = "administer empty carts",
 *     "_custom_access" = TRUE,
 *   },
 * )
 */
class UnlockCartsAction extends ActionBase {

  /**
   * {@inheritDoc}
   */
  public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
    $result = $object->access('create', $account, TRUE);

    return $return_as_object ? $result : $result->isAllowed();
  }

  /**
   * {@inheritDoc}
   */
  public function execute($order = NULL) {
    $order->set('locked', 0);
    $order->save();
  }

}

And this is the error response:

 -------------- ----------- --------------- --------------------------------- 
  Module         Update ID   Type            Description                      
 -------------- ----------- --------------- --------------------------------- 
  destilatorsh   9011        hook_update_n   9011 - Implements                
  op_cart_clea                               hook_update_N(). Add the system  
  nup                                        action for unlocking carts.      
 -------------- ----------- --------------- --------------------------------- 


 Do you wish to run the specified pending updates? (yes/no) [yes]:
 > 

>  [notice] Update started: destilatorshop_cart_cleanup_update_9011
>  [error]  The "unlock_cart" plugin does not exist. Valid plugin IDs for Drupal\Core\Action\ActionManager are: comment_unpublish_by_keyword_action, commerce_unpublish_product, commerce_publish_product, entity_delete_action:comment, entity_delete_action:commerce_order, entity_delete_action:commerce_product, entity_delete_action:commerce_promotion, entity_delete_action:commerce_store, entity_delete_action:commerce_wishlist, flag_action:izrada_po_narudzbi_flag, flag_action:izrada_po_narudzbi_unflag, flag_action:najprodavaniji_flag, flag_action:najprodavaniji_unflag, flag_action:novo_flag, flag_action:novo_unflag, flag_delete_flagging, node_unpromote_action, node_make_unsticky_action, node_promote_action, node_unpublish_by_keyword_action, node_make_sticky_action, node_assign_owner_action, redirect_delete_action, user_add_role_action, user_unblock_user_action, user_block_user_action, user_remove_role_action, user_cancel_user_action, pathauto_update_alias, action_send_email_action, action_goto_action, action_message_action, entity:publish_action:block_content, entity:publish_action:comment, entity:publish_action:commerce_product, entity:publish_action:commerce_product_variation, entity:publish_action:node, entity:publish_action:path_alias, entity:publish_action:profile, entity:publish_action:taxonomy_term, entity:publish_action:menu_link_content, entity:delete_action:comment, entity:delete_action:commerce_order, entity:delete_action:commerce_product, entity:delete_action:commerce_promotion, entity:delete_action:commerce_store, entity:delete_action:commerce_wishlist, entity:delete_action:contact_message, entity:delete_action:node, entity:delete_action:profile, entity:save_action:block_content, entity:save_action:comment, entity:save_action:commerce_order_item, entity:save_action:commerce_order, entity:save_action:commerce_payment_method, entity:save_action:commerce_product, entity:save_action:commerce_product_variation, entity:save_action:commerce_product_attribute_value, entity:save_action:commerce_promotion_coupon, entity:save_action:commerce_promotion, entity:save_action:commerce_shipment, entity:save_action:commerce_wishlist_item, entity:save_action:commerce_wishlist, entity:save_action:file, entity:save_action:node, entity:save_action:profile, entity:save_action:taxonomy_term, entity:save_action:user, entity:save_action:menu_link_content, entity:unpublish_action:block_content, entity:unpublish_action:comment, entity:unpublish_action:commerce_product, entity:unpublish_action:commerce_product_variation, entity:unpublish_action:node, entity:unpublish_action:path_alias, entity:unpublish_action:profile, entity:unpublish_action:taxonomy_term, entity:unpublish_action:menu_link_content, message_delete_action 
>  [error]  Update failed: destilatorshop_cart_cleanup_update_9011 
 [error]  Update aborted by: destilatorshop_cart_cleanup_update_9011 
 [error]  Finished performing updates.
πŸ’¬ Support request
Status

Postponed: needs info

Version

9.5

Component
Database updateΒ  β†’

Last updated 9 days ago

No maintainer
Created by

πŸ‡·πŸ‡ΈSerbia darko_antunovic

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.

Production build 0.71.5 2024