Added ability to use generators with database queries.

Adapted bulk actions to use generators.
This commit is contained in:
matthew
2019-07-05 10:24:46 -05:00
committed by Shish
parent 183f9bb897
commit d64603674e
8 changed files with 119 additions and 142 deletions

View File

@@ -246,14 +246,10 @@ class TranscodeImage extends Extension
if ($user->is_admin()) {
$format = $_POST['transcode_format'];
$total = 0;
foreach ($event->items as $id) {
foreach ($event->items as $image) {
try {
$database->beginTransaction();
$image = Image::by_id($id);
if ($image==null) {
continue;
}
$this->transcode_and_replace_image($image, $format);
// If a subsequent transcode fails, the database need to have everything about the previous transcodes recorded already,
// otherwise the image entries will be stuck pointing to missing image files