Skip to content
Snippets Groups Projects

Issue #3475680: Remove casting to int of id

1 file
+ 3
8
Compare changes
  • Side-by-side
  • Inline
@@ -58,7 +58,7 @@ class DatabaseQueue extends CoreDatabaseQueue implements QueueInterface {
'created' => time(),
]);
if ($id = $query->execute()) {
return (int) $id;
return $id;
}
return FALSE;
}
@@ -88,8 +88,6 @@ class DatabaseQueue extends CoreDatabaseQueue implements QueueInterface {
// Execute the query and finish the call.
if ($id = $query->execute()) {
$id = (int) $id;
// A multiple row-insert doesn't give back all the individual IDs, so
// calculate them back by applying subtraction.
for ($i = 1; $i <= count($records); $i++) {
@@ -130,7 +128,6 @@ class DatabaseQueue extends CoreDatabaseQueue implements QueueInterface {
$conditions = [':now' => time()];
$item = $this->connection->queryRange('SELECT * FROM {' . static::TABLE_NAME . '} q WHERE ((expire = 0) OR (:now > expire)) ORDER BY created, item_id ASC', 0, 1, $conditions)->fetchObject();
if ($item) {
$item->item_id = (int) $item->item_id;
$item->expire = (int) $item->expire;
// Try to update the item. Only one thread can succeed in UPDATEing the
@@ -174,7 +171,6 @@ class DatabaseQueue extends CoreDatabaseQueue implements QueueInterface {
continue;
}
$item_ids[] = $item->item_id;
$item->item_id = (int) $item->item_id;
$item->expire = (int) $item->expire;
$item->data = unserialize($item->data);
$returned_items[] = $item;
@@ -214,7 +210,7 @@ class DatabaseQueue extends CoreDatabaseQueue implements QueueInterface {
// Extract item IDs and serialized data so comparing becomes easier.
$items_data = [];
foreach ($items as $item) {
$items_data[intval($item->item_id)] = serialize($item->data);
$items_data[$item->item_id] = serialize($item->data);
}
// Figure out which items have changed their data and update just those.
@@ -224,7 +220,7 @@ class DatabaseQueue extends CoreDatabaseQueue implements QueueInterface {
->condition('item_id', array_keys($items_data), 'IN')
->execute();
foreach ($originals as $original) {
$item_id = intval($original->item_id);
$item_id = $original->item_id;
if ($original->data !== $items_data[$item_id]) {
$this->connection->update(static::TABLE_NAME)
->fields(['data' => $items_data[$item_id]])
@@ -327,7 +323,6 @@ class DatabaseQueue extends CoreDatabaseQueue implements QueueInterface {
if (!$item) {
continue;
}
$item->item_id = (int) $item->item_id;
$item->expire = (int) $item->expire;
$item->data = unserialize($item->data);
$items[] = $item;
Loading