Skip to content

fix: clear instance pools after adding media - #6740

Merged
gharlan merged 1 commit into
5.xfrom
fix/media-instance-pool
Oct 14, 2026
Merged

gharlan merged 1 commit into
5.xfrom
fix/media-instance-pool

Conversation

@gharlan

@gharlan gharlan commented Oct 12, 2026

Copy link
Copy Markdown
Member

Since #6674 null results are cached in the instance pool. rex_mediapool::filename() calls rex_media::get() for the candidate names and stops at the first one that returns null — so the chosen filename ends up with a cached null. rex_media_service::addMedia() didn't clear that instance, so for the rest of the request rex_media::get() returned null for the newly added media (e.g. in MEDIA_ADDED listeners, during the sync page loop, or even deleteMedia() in the same request).

Changes:

  • clear the rex_media instance of the new file in rex_media_service::addMedia()
  • clear the root_media list of rex_media in rex_media_cache::deleteList(0)/deleteLists() (only the rex_media_category lists were cleared, so rex_media::getRootMedia() stayed stale)
  • clear the mediapool instance pools on CACHE_DELETED (like the structure addon does)
  • rex_user::clearInstance() returned early for cached null entries, so they could never be cleared; it now removes the given key in that case

Since null results are cached in the instance pool, rex_mediapool::filename()
leaves a cached null for the chosen filename, so rex_media::get() returned null
for the newly added media for the rest of the request (e.g. in MEDIA_ADDED).

- clear the rex_media instance of the new file in rex_media_service::addMedia()
- clear the root media list of rex_media when media lists are deleted
- clear the mediapool instance pools on CACHE_DELETED
- let rex_user::clearInstance() also remove cached null entries
@rex-bot rex-bot added the bug label Oct 12, 2026
@gharlan gharlan added this to the REDAXO 5.21.6 milestone Oct 12, 2026
@gharlan
gharlan merged commit 5d50dbe into 5.x Oct 14, 2026
18 checks passed
@gharlan
gharlan deleted the fix/media-instance-pool branch October 14, 2026 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants