Ubuntu 16.04.6 LTS
PHP 7.3.15
Joomla 3.9.16
T3 Framework 2.7.5
This is not a PHP version issue.
You are debugging this on Linux, correct? You can experience this issue only on file systems that use a slash as the root symbol (Windows uses a drive letter, so it is not an issue there, though the code would still be wrong).
Let's assume a base path of /var/www/vhosts/mydomain.com/httpdocs
(which will be the value of JPATH_ROOT
) and the purity_iii
template. We run the original code, without the bugfix.
In t3folderlist.php:60
the following line will be executed:
$tmps = parent::getOptions();
At this point in time $this->directory
will have the value /var/www/vhosts/mydomain.com/httpdocs/templates/purity_iii/less/themes
(so the absolute path).
In the called function JFormFieldFolderList::getOptions()
in folderlist.php:187
, the following line is being executed:
$path = ltrim($this->directory, '/');
This will remove the leading slash and thus make $path
relative. It has now the value var/www/vhosts/mydomain.com/httpdocs/templates/purity_iii/less/themes
.
Then the following line will be executed:
if (!is_dir($path))
It checks, whether the path points to a valid directory, which is not the case, because this relative path does not exist (the absolute path with the leading slash would have existed).
The the following line will be executed:
if (is_dir(JPATH_ROOT . '/' . $path))
It checks whether the concatenation of JPATH_ROOT
and $path
is a valid path. The concatendation will look like this:
/var/www/vhosts/mydomain.com/httpdocs/var/www/vhosts/mydomain.com/httpdocs/templates/purity_iii/less/themes
So this is obviously also an invalid path.
Then the method returns (with null
).
So it is clear, that the JFormFieldFolderList::getOptions()
method does only work correctly, if it is being used on a relative path (because it will make all absolute paths incorrectly to relative paths).
Therefore, the fix I proposed in my previous post is the solution to the issue and will work on all systems (not just Linux but also Windows).