Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.1] Ensure isMediaFile defaults to all supported formats when mediatypes is not specified #43640

Open
wants to merge 1 commit into
base: 5.1-dev
Choose a base branch
from

Conversation

mattelkins-bluefrontier
Copy link
Contributor

@mattelkins-bluefrontier mattelkins-bluefrontier commented Jun 10, 2024

Pull Request for Issue #43640.

Summary of Changes

  • If mediatypes is not specified in the input, fallback to an explodable string of all supported formats (0,1,2,3) rather than images only (0).
  • Remove a redundant if statement - count($mediaTypes) is never === 0.

Testing Instructions

  1. Download the following file: Example MP4
  2. Upload the video file in to the root of the media library - by default, the path to the file should be: local-images:/file_example_MP4_480_1_5MG.mp4
  3. In a custom component or module, call \Joomla\Component\Media\Administrator\Model\FileModel::getFileInformation('local-images:/file_example_MP4_480_1_5MG.mp4');

Actual result BEFORE applying this Pull Request

With mediatypes not present or empty in the input object, calling FileModel::getFileInformation() with a path to anything other than an image file will generate an InvalidPathException.

The exception is thrown by ApiModel::getFile(), and will also be thrown if this function is called directly with a separate adapter and path.

The exception is triggered due to the fact that ApiModel::isMediaFile() will return false for a non-image file if mediatypes is not present or is empty in the input object. Without mediatypes, allowed formats will be limited to images only, rather than images, audio files, videos and documents.

Expected result AFTER applying this Pull Request

FileModel::getFileInformation() (and ApiModel::getFile()) will return an object containing file information for image and non-image files, assuming the referenced file exists at the location specified by the path.

(The namespace for all classes mentioned above is: Joomla\Component\Media\Administrator\Model.)

Link to documentations

No documentation changes for docs.joomla.org needed.
No documentation changes for manual.joomla.org needed.

@mattelkins-bluefrontier mattelkins-bluefrontier marked this pull request as ready for review June 10, 2024 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants