? PR-4.3-dev Pending

User tests: Successful: Unsuccessful:

avatar joomdonation
joomdonation
19 Nov 2022

Pull Request for Issue #39203.

Summary of Changes

Sometime, on a window system, value stored for a media form field has this format images\headers\banner.jpg and it will throw warning and there will be notice like below when you edit the record contains that field:

Notice: Undefined offset: 0 in ...\libraries\src\Form\Field\MediaField.php on line 294

This PR just fixes that notice.

Testing Instructions

If you want to fully re-procedure the issue, you need to have Joomla setup on windows and follow instructions at #39203 (comment) to see the issue. However, there is a simple way to re-procedure it :

  1. Add the line of code below after this line https://github.com/joomla/joomla-cms/blob/4.2-dev/libraries/src/Form/Field/MediaField.php#L263 . That will fake name of the image file in window directory separator format
$this->value = 'images\headers\banner.jpg';

Actual result BEFORE applying this Pull Request

You see notice like below:

Notice: Undefined offset: 0 in ...\libraries\src\Form\Field\MediaField.php on line 294

Expected result AFTER applying this Pull Request

No notice anymore.

avatar joomdonation joomdonation - open - 19 Nov 2022
avatar joomdonation joomdonation - change - 19 Nov 2022
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 19 Nov 2022
Category Libraries
avatar joomdonation joomdonation - change - 19 Nov 2022
The description was changed
avatar joomdonation joomdonation - edited - 19 Nov 2022
avatar richard67 richard67 - change - 19 Nov 2022
Title
[4.3] Fix Media Field with window directory separate in value
[4.3] Fix Media Field with window directory separator in value
avatar richard67 richard67 - edited - 19 Nov 2022
avatar richard67 richard67 - change - 19 Nov 2022
Title
[4.3] Fix Media Field with window directory separator in value
[4.3] Fix Media Field with Windows directory separator in value
avatar richard67 richard67 - edited - 19 Nov 2022
avatar richard67 richard67 - change - 19 Nov 2022
Labels Added: PR-4.3-dev
avatar jwaisner jwaisner - test_item - 22 Nov 2022 - Tested successfully
avatar jwaisner
jwaisner - comment - 22 Nov 2022

I have tested this item successfully on 546b4c4

Looks good. Tested on Windows 11.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39248.

avatar robbiejackson
robbiejackson - comment - 23 Nov 2022

I've tested this and can confirm that it fixes the original issue 39203 which I raised.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39248.

avatar richard67
richard67 - comment - 23 Nov 2022

I've tested this and can confirm that it fixes the original issue 39203 which I raised.

@robbiejackson Please use the blue "Test this" button at the top left corner in the issue tracker, then select your test result and then submit, so your test is properly counted. Thanks in advance.

avatar robbiejackson robbiejackson - test_item - 23 Nov 2022 - Tested successfully
avatar robbiejackson
robbiejackson - comment - 23 Nov 2022

I have tested this item successfully on 546b4c4

Tested using images uploaded from a front-end form and which resulted in the images being given pathnames which were of the Windows format (with backslashes). This included tests for wben the Media Global Config "Path to Images Folder" was set to a Windows-format pathname images\photos, as well as a linux format pathname, and the images uploaded were saved to that folder.

These image files were then treated as media form fields in the admin backend, and the tests confirmed that the fields displayed and were editable ok, both before and after the associated records (with the image pathnames) were saved to the database.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39248.

avatar richard67 richard67 - change - 23 Nov 2022
Status Pending Ready to Commit
avatar richard67
richard67 - comment - 23 Nov 2022

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39248.

avatar laoneo laoneo - change - 25 Nov 2022
Labels Added: ?
avatar laoneo laoneo - close - 25 Nov 2022
avatar laoneo laoneo - merge - 25 Nov 2022
avatar laoneo laoneo - change - 25 Nov 2022
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2022-11-25 10:19:40
Closed_By laoneo
avatar laoneo
laoneo - comment - 25 Nov 2022

Thank you!

Add a Comment

Login with GitHub to post a comment