fix: Media-Liste category_id=0 Filter + mediaIsInUse 500er absichern#32
Open
fix: Media-Liste category_id=0 Filter + mediaIsInUse 500er absichern#32
Conversation
Die Bedingung 0 < category_id hat dazu geführt, dass category_id=0 (Root-Kategorie) ignoriert wurde und stattdessen alle Medien ohne Filter zurückgegeben wurden. Jetzt wird category_id=0 korrekt als WHERE-Bedingung angewendet. Die rex_media_category::get()-Prüfung wird nur für id > 0 durchgeführt, da Root keine eigene Kategorie-Instanz hat.
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes a bug where filtering the media list by filter[category_id]=0 (root category) was incorrectly ignored, returning all media without any category filter instead. The fix correctly applies the SQL WHERE condition for category_id=0 while maintaining proper validation logic for categories with ID > 0.
Changes:
- Fixed the conditional logic to apply category_id filter for value 0 (root category)
- Extracted category_id to a variable with explicit int cast for type safety
- Moved rex_media_category validation inside a nested condition that only executes for category_id > 0
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…P-Listener zu verhindern rex_mediapool::mediaIsInUse() ruft den Extension Point MEDIA_IS_IN_USE auf. Fehlerhafte Listener (z.B. setSubject(true) statt Array) können einen TypeError auslösen. Der try-catch fängt das ab und gibt is_in_use: false als sicheren Fallback zurück.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes
1. Media-Liste
filter[category_id]=0wird jetzt korrekt verarbeitetProblem: Beim Filtern mit
filter[category_id]=0(Root-Kategorie) wurde der Filter ignoriert und alle Medien zurückgegeben.Ursache: Die Bedingung
0 < $Query["filter"]["category_id"]war fürcategory_id=0immerfalse.Fix:
category_id=0wird jetzt als SQL WHERE-Bedingung gesetztrex_media_category::get()wird nur fürid > 0geprüft (Root hat keine Kategorie-Instanz)(int)für Type Safety2.
handleGetMedia(): mediaIsInUse() in try-catch wrappenProblem:
rex_mediapool::mediaIsInUse()ruft den Extension PointMEDIA_IS_IN_USEauf. Fehlerhafte EP-Listener (z.B.$ep->setSubject(true)statt Array) können einenTypeErrorauslösen und die API mit HTTP 500 crashen lassen.Konkreter Fall:
mediapool_toolssetzte$ep->setSubject(true)statt das Warning-Array korrekt weiterzugeben. Das führte inmediapool.phpZeile 100 zuimplode("", true)→ TypeError.Fix:
mediaIsInUse()wird intry/catch(\Throwable)gewrappedis_in_use: falseals sicherer Fallback