You are here

function _acquia_purge_queue_add in Acquia Purge 6

Same name and namespace in other branches
  1. 7 acquia_purge.deprecated.inc \_acquia_purge_queue_add()

Queue manager: add a single purge to the queue.

@returns The total amount of items in the queue (int).

Parameters

string $path: The Drupal path (e.g. '<front>', 'user/1' or an aliased path).

2 calls to _acquia_purge_queue_add()
acquia_purge_purge_path in ./acquia_purge.module
Purge a certain Drupal path from Varnish.
acquia_purge_purge_paths in ./acquia_purge.module
Purge a several Drupal paths from Varnish.

File

./acquia_purge.module, line 616
Acquia Purge, Top-notch Varnish purging on Acquia Cloud!

Code

function _acquia_purge_queue_add($path) {
  $qcount = variable_get('acquia_purge_queue_counter', 0);

  // Add the non-associative purge item definition.
  db_query("INSERT INTO {ap_queue} (path) VALUES ('%s')", $path);

  // Bump the queue counter.
  $qcount++;

  // Register the currently logged on user as one of the queue owners. These
  // users are given the AJAX client side script until the queue is empty.
  static $owner_registered;
  if (is_null($owner_registered) && php_sapi_name() != 'cli') {
    global $user;

    // Only register authenticated users, anonymous users will only queue.
    if (isset($user->roles[DRUPAL_AUTHENTICATED_RID])) {
      $owners = variable_get('acquia_purge_queue_owners', array());
      if (!in_array($user->name, $owners)) {
        $owners[] = $user->name;
        variable_set('acquia_purge_queue_owners', $owners);
      }
      $owner_registered = TRUE;
    }
  }

  // Store the queue counter in our state variable.
  variable_set('acquia_purge_queue_counter', $qcount);
  return $qcount;
}