Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Maarch
MaarchCourrier
Commits
73596451
Commit
73596451
authored
Sep 09, 2021
by
Quentin Ribac
Browse files
FIX #17703 TIME 0:05 secure removeOrphanedEntities when first entity in table is at root level
parent
da16fbe8
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/app/entity/models/EntityModelAbstract.php
View file @
73596451
...
...
@@ -498,13 +498,12 @@ abstract class EntityModelAbstract
public
static
function
removeOrphanedEntities
(
array
$entities
)
{
if
(
!
isset
(
$entities
[
0
][
'parent_entity_id'
])
||
!
isset
(
$entities
[
0
][
'entity_id'
]))
{
return
$entities
;
}
do
{
$entitiesCount
=
count
(
$entities
);
$entitiesIds
=
array_column
(
$entities
,
'entity_id'
);
if
(
empty
(
$entitiesIds
))
{
return
$entities
;
}
$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
));
}));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment