Commit cecccd70 authored by Quentin Ribac's avatar Quentin Ribac
Browse files

FIX #17703 TIME 0:05 secure removeOrphanedEntities when first entity in table is at root level

parent 6f9fc6db
...@@ -498,13 +498,12 @@ abstract class EntityModelAbstract ...@@ -498,13 +498,12 @@ abstract class EntityModelAbstract
public static function removeOrphanedEntities(array $entities) public static function removeOrphanedEntities(array $entities)
{ {
if (!isset($entities[0]['parent_entity_id']) || !isset($entities[0]['entity_id'])) {
return $entities;
}
do { do {
$entitiesCount = count($entities); $entitiesCount = count($entities);
$entitiesIds = array_column($entities, 'entity_id'); $entitiesIds = array_column($entities, 'entity_id');
if (empty($entitiesIds)) {
return $entities;
}
$entities = array_values(array_filter($entities, function($entity) use ($entitiesIds) { $entities = array_values(array_filter($entities, function($entity) use ($entitiesIds) {
return empty($entity['parent_entity_id']) || ($entity['parent_entity_id'] != $entity['entity_id'] && in_array($entity['parent_entity_id'], $entitiesIds)); return empty($entity['parent_entity_id']) || ($entity['parent_entity_id'] != $entity['entity_id'] && in_array($entity['parent_entity_id'], $entitiesIds));
})); }));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment