?
avatar corejoomla
corejoomla
17 Feb 2018

Steps to reproduce the issue

Load two different files with the different base locations but with same name.

JLoader::import('somemodel', JPATH_ROOT.'/components/com_mycomponent1/models');
JLoader::import('somemodel', JPATH_ROOT.'/components/com_mycomponent2/models');

Expected result

Models from each component are loaded and can be used.
JModelLegacy::getInstance( 'somemodel', 'MyComponent2Model' ); should result model object.

Actual result

JModelLegacy::getInstance( 'somemodel', 'MyComponent2Model' ); results in false value

System information (as much as possible)

Joomla 3.8.5

avatar corejoomla corejoomla - open - 17 Feb 2018
avatar joomla-cms-bot joomla-cms-bot - change - 17 Feb 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 17 Feb 2018
avatar corejoomla corejoomla - change - 17 Feb 2018
The description was changed
avatar corejoomla corejoomla - edited - 17 Feb 2018
avatar corejoomla corejoomla - change - 17 Feb 2018
The description was changed
avatar corejoomla corejoomla - edited - 17 Feb 2018
avatar franz-wohlkoenig franz-wohlkoenig - change - 17 Feb 2018
Category com_plugins
avatar mbabker
mbabker - comment - 17 Feb 2018

JLoader::import() works with a dot separated key to load files, it is the class method used by jimport(), so its proper use would be JLoader::import('joomla.filesystem.file') (note the method also has very explicit class name expectations, component model classes wouldn't fit the convention).

You should either use JLoader::register() to register class names to the autoloader, or JModelLegacy::addIncludePath() to register the lookup paths for your models.

avatar franz-wohlkoenig franz-wohlkoenig - change - 17 Feb 2018
Status New Information Required
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 21 Feb 2018

@corejoomla can this Issue be closed?

avatar corejoomla
corejoomla - comment - 3 Mar 2018

Thanks for the clarifications. This issue can be closed.

avatar corejoomla corejoomla - change - 3 Mar 2018
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2018-03-03 16:58:47
Closed_By corejoomla
avatar corejoomla corejoomla - close - 3 Mar 2018

Add a Comment

Login with GitHub to post a comment