Wrong Orphan Result Due to Logical Bug in getUsedMediaIds Method

Created on 4 July 2025, 29 days ago

Problem/Motivation

The getUsedMediaIds method in the OrphansMediaManager class has a logical issue. The $currentList variable is initialized inside the loop but never actually gets updated or used properly. Because of that, the array_merge($currentList, $mediaIds) line isn’t doing what it’s supposed to — $currentList is always just an empty array.

As a result, the method might incorrectly flag media items as orphans. For example, if Media C is used by an entity of type A but not by an entity of type B, it could still be marked as an orphan even though it’s in use.

Steps to reproduce

  1. Reference an orphaned media item with an entity type that has lower index in entityTypeManager->getDefinitions().
  2. Verify that the media item still appears as an orphan.

Proposed resolution

Fix the line 111 of the OrphansMediaManager class.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom jhan1112 Birmingham

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024