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

folderlist joomla core field returns full paths instead of folder path #11102

Closed
wronax opened this Issue Jul 13, 2016 · 5 comments

Comments

Projects
None yet
5 participants
@wronax

wronax commented Jul 13, 2016

Steps to reproduce the issue

This issue can be reproduce on windows servers with backslash as a folder separator.

You can see this in DJ-MegaMenu module where folderlist field is used for selecting theme

<field name="theme" type="folderlist" default="default" label="MOD_DJMEGAMENU_THEME" description="MOD_DJMEGAMENU_THEME_DESC" directory="modules/mod_djmegamenu/themes" hide_none="true" hide_default="true">
    <option value="_override">MOD_DJMEGAMENU_THEME_OVERRIDE</option>
    <option value="_custom">MOD_DJMEGAMENU_CUSTOM_THEME</option>
</field>

Expected result

- override -
- custom -
classic
default

Actual result

- override -
- custom -
C:\xampp\htdocs\joomla3\modules\mod_djmegamenu\themes/classic
C:\xampp\htdocs\joomla3\modules\mod_djmegamenu\themes/default

System information (as much as possible)

PHP 5.4.4

Additional comments

This can be fixed by replacing the 189 line in libraries/joomla/form/fields/folderlist.php file

$path = JPATH_ROOT . '/' . $path;

with

$path = JPath::clean(JPATH_ROOT . '/' . $path);
@faugro

This comment has been minimized.

Show comment
Hide comment
@faugro

faugro Jul 14, 2016

$path = JPath::clean(JPATH_ROOT . '/' . $path);

not solved the problem.
In my case the slash start change to backslash after line 204

$folders = JFolder::folders($path, $this->filter, $this->recursive, true);

so, for a while i add code to replace backslash to forwardslash on line 221, so it will be

$folder = str_replace('\\', '/', $folder);
$folder = trim(str_replace($path, '', $folder), '/');

I'm working on wamp in windows 7, have not test it on another environment yet.

faugro commented Jul 14, 2016

$path = JPath::clean(JPATH_ROOT . '/' . $path);

not solved the problem.
In my case the slash start change to backslash after line 204

$folders = JFolder::folders($path, $this->filter, $this->recursive, true);

so, for a while i add code to replace backslash to forwardslash on line 221, so it will be

$folder = str_replace('\\', '/', $folder);
$folder = trim(str_replace($path, '', $folder), '/');

I'm working on wamp in windows 7, have not test it on another environment yet.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Jul 14, 2016

You also can use JPath::clean but with an additional parameter '/'. Otherwise DIRECTRORY_SEPARATOR is used in clean(...).

$folder = JPath::clean(JPATH_ROOT . '/' . $folder , '/');
$folder = ...

ghost commented Jul 14, 2016

You also can use JPath::clean but with an additional parameter '/'. Otherwise DIRECTRORY_SEPARATOR is used in clean(...).

$folder = JPath::clean(JPATH_ROOT . '/' . $folder , '/');
$folder = ...
@wronax

This comment has been minimized.

Show comment
Hide comment
@wronax

wronax Jul 18, 2016

@faugro
JPath::clean returns the server path to the folder, so it can contain backslashes or slashes depends on server UX.

The same $path is used as a starting point to find folders, then the $path is removed from folder paths, so how can you get backslashes in the returned folder list while JFolder::_items function use clean text slash and not DIRECTORY_SEPARATON ?

Is there anyone who can check this and create a pull request?

wronax commented Jul 18, 2016

@faugro
JPath::clean returns the server path to the folder, so it can contain backslashes or slashes depends on server UX.

The same $path is used as a starting point to find folders, then the $path is removed from folder paths, so how can you get backslashes in the returned folder list while JFolder::_items function use clean text slash and not DIRECTORY_SEPARATON ?

Is there anyone who can check this and create a pull request?

@cheesegrits

This comment has been minimized.

Show comment
Hide comment
@cheesegrits

cheesegrits Jul 24, 2016

Contributor

I've submitted a PR:

#11288

Anyone interested in getting this merged should test it, and report test results on the PR.


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

cheesegrits commented Jul 24, 2016

I've submitted a PR:

#11288

Anyone interested in getting this merged should test it, and report test results on the PR.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11102.
@brianteeman

This comment has been minimized.

Show comment
Hide comment
@brianteeman

brianteeman Jul 25, 2016

Contributor

Closed as we have a PR for testing - thanks


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

Contributor

brianteeman commented Jul 25, 2016

Closed as we have a PR for testing - thanks


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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment