Skip to content
Snippets Groups Projects
Select Git revision
  • c9e01c6e89dc910140a6af0f07796036e6f0afed
  • 11.x default protected
  • 11.2.x protected
  • 10.5.x protected
  • 10.6.x protected
  • 11.1.x protected
  • 10.4.x protected
  • 11.0.x protected
  • 10.3.x protected
  • 7.x protected
  • 10.2.x protected
  • 10.1.x protected
  • 9.5.x protected
  • 10.0.x protected
  • 9.4.x protected
  • 9.3.x protected
  • 9.2.x protected
  • 9.1.x protected
  • 8.9.x protected
  • 9.0.x protected
  • 8.8.x protected
  • 10.5.2 protected
  • 11.2.3 protected
  • 10.5.1 protected
  • 11.2.2 protected
  • 11.2.1 protected
  • 11.2.0 protected
  • 10.5.0 protected
  • 11.2.0-rc2 protected
  • 10.5.0-rc1 protected
  • 11.2.0-rc1 protected
  • 10.4.8 protected
  • 11.1.8 protected
  • 10.5.0-beta1 protected
  • 11.2.0-beta1 protected
  • 11.2.0-alpha1 protected
  • 10.4.7 protected
  • 11.1.7 protected
  • 10.4.6 protected
  • 11.1.6 protected
  • 10.3.14 protected
41 results

batch.queue.inc

Blame
  • Nathan Haug's avatar
    Issue #22336 by quicksketch, scor, boombatower, and rfay. Move all core Drupal...
    Nate Lampton authored and Nathaniel committed
    Issue #22336 by quicksketch, scor, boombatower, and rfay. Move all core Drupal files under a core subdirectory.
    06fb770b
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    batch.queue.inc 1.77 KiB
    <?php
    
    
    /**
     * @file
     * Queue handlers used by the Batch API.
     *
     * Those implementations:
     * - ensure FIFO ordering,
     * - let an item be repeatedly claimed until it is actually deleted (no notion
     *   of lease time or 'expire' date), to allow multipass operations.
     */
    
    /**
     * Batch queue implementation.
     *
     * Stale items from failed batches are cleaned from the {queue} table on cron
     * using the 'created' date.
     */
    class BatchQueue extends SystemQueue {
    
      public function claimItem($lease_time = 0) {
        $item = db_query_range('SELECT data, item_id FROM {queue} q WHERE name = :name ORDER BY item_id ASC', 0, 1, array(':name' => $this->name))->fetchObject();
        if ($item) {
          $item->data = unserialize($item->data);
          return $item;
        }
        return FALSE;
      }
    
      /**
       * Retrieve all remaining items in the queue.
       *
       * This is specific to Batch API and is not part of the DrupalQueueInterface,
       */
      public function getAllItems() {
        $result = array();
        $items = db_query('SELECT data FROM {queue} q WHERE name = :name ORDER BY item_id ASC', array(':name' => $this->name))->fetchAll();
        foreach ($items as $item) {
          $result[] = unserialize($item->data);
        }
        return $result;
      }
    }
    
    /**
     * Batch queue implementation used for non-progressive batches.
     */
    class BatchMemoryQueue extends MemoryQueue {
    
      public function claimItem($lease_time = 0) {
        if (!empty($this->queue)) {
          reset($this->queue);
          return current($this->queue);
        }
        return FALSE;
      }
    
      /**
       * Retrieve all remaining items in the queue.
       *
       * This is specific to Batch API and is not part of the DrupalQueueInterface,
       */
      public function getAllItems() {
        $result = array();
        foreach ($this->queue as $item) {
          $result[] = $item->data;
        }
        return $result;
      }
    }