protected function UniqueQueueTest::createItemMd5 in Queue Unique 8.2
Adds a queue item and store it directly to the queue.
This code mimics the code that was in UniqueDatabaseQueue::doCreateItem() before the update to sha2.
Parameters
string $name: The queue name.
$data: Arbitrary data to be associated with the new task in the queue.
Return value
A unique ID if the item was successfully created. False otherwise.
1 call to UniqueQueueTest::createItemMd5()
- UniqueQueueTest::testUpdateHook8001 in tests/
src/ Kernel/ UniqueQueueTest.php - Test queue_unique_update_8001().
File
- tests/
src/ Kernel/ UniqueQueueTest.php, line 161
Class
- UniqueQueueTest
- Unique queue kernel test.
Namespace
Drupal\Tests\queue_unique\KernelCode
protected function createItemMd5($name, $data) {
$connection = $this->container
->get('database');
try {
$query = $connection
->insert(UniqueDatabaseQueue::TABLE_NAME)
->fields([
'name' => $name,
'data' => serialize($data),
'created' => time(),
// Generate a unique value for this data on this queue. This value
// is ignored by the update hook, so we can use any hash.
'md5' => substr(hash('sha512', $name . serialize($data)), 0, 32),
]);
return $query
->execute();
} catch (IntegrityConstraintViolationException $e) {
return FALSE;
}
}