[Queue_item] Let DataObject construct WHERE IN

This commit is contained in:
Alexei Sorokin 2020-08-24 16:16:00 +03:00
parent 20e5a6d1f3
commit b419c5cf7c

View File

@ -61,20 +61,24 @@ class Queue_item extends Managed_DataObject
$qi = new Queue_item(); $qi = new Queue_item();
if ($transports) { if ($transports) {
if (is_array($transports)) { if (is_array($transports)) {
// @fixme use safer escaping $qi->whereAddIn(
$list = implode("','", array_map(array($qi, 'escape'), $transports)); 'transport',
$qi->whereAdd("transport in ('$list')"); $transports,
$qi->columnType('transport')
);
} else { } else {
$qi->transport = $transports; $qi->transport = $transports;
} }
} }
if (!empty($ignored_transports)) { if (!empty($ignored_transports)) {
// @fixme use safer escaping $qi->whereAddIn(
$list = implode("','", array_map(array($qi, 'escape'), $ignored_transports)); '!transport',
$qi->whereAdd("transport NOT IN ('$list')"); $ignored_transports,
$qi->columnType('transport')
);
} }
$qi->whereAdd('claimed IS NULL');
$qi->orderBy('created'); $qi->orderBy('created');
$qi->whereAdd('claimed is null');
$qi->limit(1); $qi->limit(1);
@ -95,7 +99,7 @@ class Queue_item extends Managed_DataObject
common_log(LOG_ERR, 'claim of queue item id= ' . $qi->getID() . ' for transport ' . $qi->transport . ' failed.'); common_log(LOG_ERR, 'claim of queue item id= ' . $qi->getID() . ' for transport ' . $qi->transport . ' failed.');
} }
} }
$qi = null; unset($qi);
return null; return null;
} }