? Pending

User tests: Successful: Unsuccessful:

avatar dgrammatiko
dgrammatiko
13 Mar 2022

Pull Request for Issue #37241 (comment) .

Summary of Changes

  • Change the conditional from checking if a folder exists to determine if it's a relative or absolute path to checking the first character

Testing Instructions

  • Goto administrator/index.php?option=com_languages&view=language&layout=edit&lang_id=1 and check that the selector for the language images still works
  • Edit
    <field
    name="image"
    type="filelist"
    label="COM_LANGUAGES_FIELD_IMAGE_LABEL"
    stripext="1"
    directory="media/mod_languages/images/"
    hide_none="1"
    hide_default="1"
    fileFilter="\.gif$"
    validate="options"
    >
    <option value="">JNONE</option>
    </field>
    to something like (provide a folder outside of Joomla's root that has some files)
<field
	name="image"
	type="filelist"
	label="COM_LANGUAGES_FIELD_IMAGE_LABEL"
	stripext="1"
	directory="/Users/dgrammatiko/Downloads"
	hide_none="1"
	hide_default="1"
	>
	<option value="">JNONE</option>
</field>

Actual result BEFORE applying this Pull Request

Expected result AFTER applying this Pull Request

  • Relative path:

Screenshot 2022-03-13 at 16 15 39

  • Absolute path:

Screenshot 2022-03-13 at 16 14 07

Documentation Changes Required

avatar dgrammatiko dgrammatiko - open - 13 Mar 2022
avatar dgrammatiko dgrammatiko - change - 13 Mar 2022
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 13 Mar 2022
Category Libraries
avatar richard67
richard67 - comment - 13 Mar 2022

@dgrammatiko There is a similar field for folder list where we have slightly different code:

https://github.com/joomla/joomla-cms/blob/4.1-dev/libraries/src/Form/Field/FolderlistField.php#L188-L202

But from my point of view those 2 fields FilelistField and FolderlistField should behave in the same way regarding the "directory" option.

Could you change it there, too, in the same way as in this PR here?

@HLeithner Or should we do it differently?

avatar dgrammatiko dgrammatiko - change - 13 Mar 2022
Labels Added: ?
avatar dgrammatiko
dgrammatiko - comment - 13 Mar 2022

@richard67 done, but I think what @HLeithner was suggesting was to not rely on the folder check for deciding if a folder is absolute or relative. Anyways I'll leave that to you...

avatar richard67
richard67 - comment - 13 Mar 2022

@richard67 done, but I think what @HLeithner was suggesting was to not rely on the folder check for deciding if a folder is absolute or relative. Anyways I'll leave that to you...

@dgrammatiko Yes, I understood that, so I thought it should be changed in the FolderlistField.php, too. Now you did it vice versa :-)

avatar richard67
richard67 - comment - 13 Mar 2022

For testing instructions, the folder list field could be tested e.g. here:

https://github.com/joomla/joomla-cms/blob/4.1-dev/plugins/editors/tinymce/forms/setoptions.xml#L22-L29

avatar dgrammatiko
dgrammatiko - comment - 13 Mar 2022

@richard67 I think we need a quick test if an absolute folder works on windows, otherwise it's obvious that the choice of is_dir for the conditional was done to satisfy that OS

avatar richard67
richard67 - comment - 13 Mar 2022

@richard67 I think we need a quick test if an absolute folder works on windows, otherwise it's obvious that the choice of is_dir for the conditional was done to satisfy that OS

@dgrammatiko Yes, I know. Unfortunately my Windows environment is not ready yet. Will check later tonight.

avatar HLeithner
HLeithner - comment - 13 Mar 2022

yes sorry my fault thanks richard

avatar dgrammatiko
dgrammatiko - comment - 13 Mar 2022

5 locs, 50+ commits...

avatar richard67
richard67 - comment - 13 Mar 2022

5 locs, 50+ commits...

@dgrammatiko True team work ?

avatar richard67
richard67 - comment - 13 Mar 2022

I don't wanna ruin the party, but ... isn't it some kind of a b/c break? In past, if someone did not have any base dir restriction which blocked that, the check e.g. for /somefolder existing in the root failed, so we prepended JPATH_ROOT and treated it like a relative folder, and if that existed all was fine from the user's point of view. Now this will not work anymore.

avatar richard67
richard67 - comment - 13 Mar 2022

@dgrammatiko @HLeithner There could be indeed a problem on Windows when using a drive letter. When the htdocs folder and the folder used in the absolute path are on the same drive C:, an absolute path like "/Users/Richard/Pictures" works. But "C:/Users/Richard/Pictures" doesn't work anymore because that absolute path starts with a drive letter and not a slash.

Without this PR, an absolute path with a drive letter like "C:/Users/Richard/Pictures" works.

avatar dgrammatiko
dgrammatiko - comment - 13 Mar 2022

Without this PR, an absolute path with a drive letter like "C:/Users/Richard/Pictures" works.

Well, there we have our answer why the conditional was using is_dir
I think this one served it's purpose, so I'm closing

avatar dgrammatiko dgrammatiko - change - 13 Mar 2022
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2022-03-13 21:25:21
Closed_By dgrammatiko
avatar dgrammatiko dgrammatiko - close - 13 Mar 2022

Add a Comment

Login with GitHub to post a comment