No Code Attached Yet bug
avatar bassmanpaul
bassmanpaul
12 Nov 2020

Hi, I'm not sure if this is expected behaviour or not but I have 2 extensions that have their own namespaced HTML classes, but because the file names are the same they conflict due to the HTMLHelper only looking at a single stack of static include paths.

For example:

Extension 1

JHTML::addIncludePath( 'components/com_one/html/' );
HTMLHelper::_( 'onehtml.framework.core' ); // class: OneHtmlFramework->core();

Extension 2

JHTML::addIncludePath( 'components/com_two/html/' );
HTMLHelper::_( 'twohtml.framework.core' ); // class: TwoHtmlFramework->core();

But because they both have a framework.php file the HTMLHelper matches the first path it finds in the includes array which for one of the extensions will throw an exception (src/HTML/HTMLHelper.php line ~129).

What the helper does is:

  1. Find a path in the includes array that has the framework.php in it.
  2. Try to load the class.
  3. Throw an exception on failure.
$path = \JPath::find(static::$includePaths, strtolower($file) . '.php');

if (!$path)
{
	throw new \InvalidArgumentException(sprintf('%s %s not found.', $prefix, $file), 500);
}

\JLoader::register($className, $path);

if (!class_exists($className))
{
	throw new \InvalidArgumentException(sprintf('%s not found.', $className), 500);
}

Should it not loop through the available paths until it finds a path match and a class match, then throw an exception after failing to find one?

avatar bassmanpaul bassmanpaul - open - 12 Nov 2020
avatar joomla-cms-bot joomla-cms-bot - change - 12 Nov 2020
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 12 Nov 2020
avatar Hackwar Hackwar - change - 20 Feb 2023
Labels Added: No Code Attached Yet bug
Removed: ?
avatar Hackwar Hackwar - labeled - 20 Feb 2023

Add a Comment

Login with GitHub to post a comment