As a matter of fact, the T4 system plugin breaks the entire Joomla 4 Console application, not just Akeeba Backup.
Even though it is a System plugin you should be aware that it no longer loads just in the context of the Site and the Administrator application. Joomla 4 introduced two more applications, the Api application and the Console application. The latter is what your plugin is causing a problem with.
The Console (CLI) application is accessible by executing the cli/joomla.php file. It has some internal commands but, most importantly, it can be extended by third party extensions using plugins in the ‘console’ group. We are using it extensively in our software to provide CLI commands which replace our old CLI scripts.
The Console application does not provide full support for the \Joomla\CMS\Uri\Uri (formerly JUri) class. The reason is actually inherent to Joomla’s Uri class internal workings, namely that the $_SERVER
superglobal does not have the HOST
key. Joomla then tries to fall back to an old IIS compatibility mode which ends up trying to parse the script's filesystem path as a URI. If course it cannot be parsed and causes the Uri class to throw an Exception. Since your plugin is using the Uri class it causes that internal error to be thrown which prevents any Console command from running. Joomla's application dies BEFORE it can load any console
plugins which register third party commands.
As a result, your plugin is breaking one of the official Joomla applications. This is something that you need to fix.
I am not going to let you on the lurch and have you figure it our yourself. I can tell you how. It's simple! In your methods which handle Joomla events add the following code:
if (!(\Joomla\CMS\Factory::getApplication() instanceof \Joomla\CMS\Application\WebApplication)) return;
This code works because the Site, Administrator and API applications all extend from WebApplication whereas the ConsoleApplication does not.
If you have plugins which need to only run under the Site and/or Administrator applications (not even the Api application) you should instead do:
$app = \Joomla\CMS\Factory::getApplication();
if (!$app->isClient(‘site’) && !$app->isClient(‘administrator’)) return;
Finally, please note that whenever you are about to access the application’s document object you should check that a. The application object has a getDocument
method and b. The document object is an instance of \Joomla\CMS\Document\HtmlDocument
. This prevents non–HTML pages from breaking e.g. JSON output which is something that we also use in our extensions and now Joomla 4 itself is using as well.
All of the code examples provided above work with Joomla 3.9, 4.0 and 4.1. If you need to support older versions of Joomla you should wrap that code in if–blocks to handle older versions.
Please let me know about your intended timeline to fix the Console application compatibility issue so I can notify our mutual clients. I believe they will appreciate us working together.
Have a great day,
Nicholas K. Dionysopoulos
Owner and lead developer, Akeeba Ltd