I have a feature request to be able to remove still queued items from the queue. An obvious solution to this is to add, or support, a Views Bulk Operation.

One way would be to support entity (api) delete; another to add actions to change the status more generally. Anything I'm assume would still have to respect locking appropriately.

Any particular way of doing this more likely to be better/get committed?

Comments

ekes’s picture

This is adding support for entity api delete (at its most basic):-

diff --git a/advancedqueue.module b/advancedqueue.module
index 396b31b..c91eff8 100644
--- a/advancedqueue.module
+++ b/advancedqueue.module
@@ -37,10 +37,21 @@ function advancedqueue_entity_info() {
     'entity keys' => array(
       'id' => 'item_id',
     ),
+    'deletion callback' => 'advancedqueue_item_delete',
   );
   return $entity_info;
 }
 
+function advancedqueue_item_delete($id) {
+  if ($item = current(entity_load('advancedqueue_item', array($id)))) {
+    if ($item->status != ADVANCEDQUEUE_STATUS_PROCESSING || $item->expire < time()) {
+      $queue = DrupalQueue::get($item->name);
+      unset($item->status);
+      $queue->deleteItem($item);
+    }
+  }
+}
+
 /**
  * Implements hook_cron().
  */

Of course by default deleted here means change to 'success' which is a little confusing.

Kazanir’s picture

Issue summary: View changes

We can just support the EntityAPIController instead, if it exists. That will make the delete action VBO supplies work fine, as well as giving improved DX to the big majority of developers who are using the Entity API module for other reasons.

  • Kazanir committed 28aa8b6 on 7.x-1.x
    Issue #1998326 by Kazanir: Add VBO support to change status
    
Kazanir’s picture

Status: Active » Fixed

Alright, now the delete item and modify entity values VBO actions should "just work" thanks to using the EntityAPIController class if it is available.

  • Kazanir committed cc3227d on 7.x-1.x
    Issue #1998326 by Kazanir: Add VBO support to change status, part deux
    
Kazanir’s picture

Needed some property setters for the entity value action to actually work properly.

Status: Fixed » Closed (fixed)

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