protected function DrupalCommerceEntityController::buildQuery in Commerce Core 7
Override of DrupalDefaultEntityController::buildQuery().
Handle pessimistic locking.
Overrides DrupalDefaultEntityController::buildQuery
File
- includes/
commerce.controller.inc, line 59 - Provides a central controller for Drupal Commerce.
Class
- DrupalCommerceEntityController
- Default implementation of DrupalCommerceEntityControllerInterface.
Code
protected function buildQuery($ids, $conditions = array(), $revision_id = FALSE) {
$query = parent::buildQuery($ids, $conditions, $revision_id);
if (isset($this->entityInfo['locking mode']) && $this->entityInfo['locking mode'] == 'pessimistic') {
// In pessimistic locking mode, we issue the load query with a FOR UPDATE
// clause. This will block all other load queries to the loaded objects
// but requires us to start a transaction.
if (empty($this->controllerTransaction)) {
$this->controllerTransaction = db_transaction();
}
$query
->forUpdate();
// Store the ids of the entities in the lockedEntities array for later
// tracking, flipped for easier management via unset() below.
if (is_array($ids)) {
$this->lockedEntities += array_flip($ids);
}
}
return $query;
}