Issue 10050: Improve photo deletions
This commit is contained in:
parent
c48179fbde
commit
49919b5b1d
1 changed files with 8 additions and 3 deletions
|
@ -364,15 +364,20 @@ class Photo
|
||||||
public static function delete(array $conditions, array $options = [])
|
public static function delete(array $conditions, array $options = [])
|
||||||
{
|
{
|
||||||
// get photo to delete data info
|
// get photo to delete data info
|
||||||
$photos = self::selectToArray(['backend-class', 'backend-ref'], $conditions);
|
$photos = DBA::select('photo', ['id', 'backend-class', 'backend-ref'], $conditions);
|
||||||
|
|
||||||
foreach($photos as $photo) {
|
while ($photo = DBA::fetch($photos)) {
|
||||||
$backend_class = DI::storageManager()->getByName($photo['backend-class'] ?? '');
|
$backend_class = DI::storageManager()->getByName($photo['backend-class'] ?? '');
|
||||||
if ($backend_class !== null) {
|
if ($backend_class !== null) {
|
||||||
$backend_class->delete($photo["backend-ref"] ?? '');
|
if ($backend_class->delete($photo["backend-ref"] ?? '')) {
|
||||||
|
// Delete the photos after they had been deleted successfully
|
||||||
|
DBA::delete("photo", ['id' => $photo['id']]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DBA::close($photos);
|
||||||
|
|
||||||
return DBA::delete("photo", $conditions, $options);
|
return DBA::delete("photo", $conditions, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue