User tests: Successful: Unsuccessful:
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.
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.)
No documentation changes for docs.joomla.org needed.
No documentation changes for manual.joomla.org needed.
Status | New | ⇒ | Pending |
Category | ⇒ | Administration com_media |
Labels |
Added:
PR-5.1-dev
|
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2024-08-14 06:59:46 |
Closed_By | ⇒ | mattelkins-bluefrontier | |
Labels |
Added:
Updates Requested
|
Thanks for your feedback, @bembelimen. I'll reopen this against 5.2-dev.
Thanks for the contribution @mattelkins-bluefrontier
I see one issue here: if you remove the
if
then you have a different behaviour to before when sending an empty string asmediatypes
:Before PR:
after the
if
you still have all types selectedAfter PR:
after the if, it's still an empty sting
Reason
$input->get(...)
only returns the default value if the value is not set at all, but an empty string counts as not empty withisset
.Also please check the XML if you change default values.