I am converting some Joomla 3 CLI applications to use the Joomla Console and this message is causing my new CLI's to fail. There are various entries in Joomla tracker relating to similar issues where core functions are not handling being in the Cli Application correctly but I haven't found anything looks like a permanent fix.

In this case I am using old style call to get a model where I am not in position to use a newer method to access my model until a related component is upgraded to J4 where the problem may no longer exist.

BaseDatabaseModel::getInstance('Inventory', 'InventoryModel')

which is then invoking the plugins which is where the actual call to the template function is coming from \libraries\src\Plugin\PluginHelper.php

$templateObj   = Factory::getApplication()->getTemplate(true);

I have a work around that involves modifying the core code of \libraries\src\Application\ConsoleApplication.php and adding a simple function to handle the call to the method that does not exist.

public function getTemplate() { return false; }

This is not something I want to have to do and remember to do each time I do an update.

In the earlier Joomla 3 version of my CLI's the above line of code was added to the bottom of the class to handle the same/similar issue, effectively this is what I am doing in the ConsoleApplication class.

My question is can anyone provide a solution or direct me to a solution that doesn't involve modifying the core code?

There are issues open on Joomla's Issue Tracker that refer to this issue like https://github.com/joomla/joomla-cms/pull/39550, https://github.com/joomla/joomla-cms/pull/38222 and https://github.com/joomla/joomla-cms/pull/38585 in the pluginHelper and the fileLayout classes so i am hoping any improved work around is not going to be required for too long.

  • You need to find out what's calling the method. Enable debug and inspect the stack trace.
    – Sharky
    Jan 19, 2023 at 9:20
  • @Sharky I have updated the original post with the extra information in that the call is coming from the PluginHelper, another piece of core code that I can't change but is needed because the model uses Plugins to get external data via an API.
    – Irata
    Jan 19, 2023 at 9:42
  • Does the plugin intentionally use layouts in the console application? Or is it something that is only meant to be done in web context? Lack of proper environment checks is a very common issue in plugins.
    – Sharky
    Jan 19, 2023 at 9:57
  • No my code doesn't need the layout in either the web or the cli context. It is again core Joomla code that is causing this by not doing a proper check of the context as you say. In this case it is the custom fields helper FieldsPlugin.php that is calling PluginHelper.php that calls the layout. That is for the core developers to address, my question is looking for any 'hack' that I can use avoid updating the core manually until the issue is resolved permanently.
    – Irata
    Jan 19, 2023 at 19:12

1 Answer 1


This pull request waiting on Joomla 4.3 is a replacement for the introduction of custom fields being searchable in com_finder that introduced the underlying issue originally. It appears that it will resolve the issue.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.