No errors
RuntimeException {#233
#message: "Could not parse the requested URI http:///var/www/clients/j41/cli/actionlogsproblem.php"
#code: 0
#file: "/var/www/clients/j41/libraries/vendor/joomla/uri/src/AbstractUri.php"
#line: 373
trace: {
/var/www/clients/j41/libraries/vendor/joomla/uri/src/AbstractUri.php:373 { …}
/var/www/clients/j41/libraries/src/Uri/Uri.php:290 {
Joomla\CMS\Uri\Uri->parse($uri)^
› {
› return parent::parse($uri);
› }
}
/var/www/clients/j41/libraries/vendor/joomla/uri/src/AbstractUri.php:111 { …}
...
Joomla 4.2
The test script is attempting to load the ActionLogs model using
$model = \Joomla\CMS\Factory::getApplication()->bootComponent('com_actionlogs') ->getMVCFactory()->createModel('Actionlog', 'Administrator', ['ignore_request' => true]);
BUT libraries/src/Extension/Service/Provider/MVCFactory.php register method in Joomla 4.2 loads the SiteRouter class without checking the fact that its being run in a ConsoleApplication
One fix is to change the register method of libraries/src/Extension/Service/Provider/MVCFactory.php to read to check for a console application e.g.
if (! \Joomla\CMS\Factory::getApplication()->isClient('cli')) { $factory->setSiteRouter($container->get(SiteRouter::class)); }
I don't know why this line was added in Joomla 4.2.
If this looks like a sensible approach I'll pull together a Pull Request.
Labels |
Added:
No Code Attached Yet
|
@wilsonge Your in ConsoleApplication resolves the issue
$this->set('uri.request', $uri->toString());
As does Nicholas' change to the cli application itself
$app->set('uri.request', 'https://console.invalid');
Personally I don't see why a console application should be responsible for setting a uri.request just in case its used somewhere in the code
It depends on what you're doing. In some cases you might still be outputting urls or building URLs. In this case the CLI will need such a property. I agree that just getting a component mvc factory shouldn't necessarily require a siterouter object (hence I tagged @laoneo ) - but depending on JFactory isn't really the solution either - for example booting up an admin controller in the CLI is totally valid and it's hard to tell when you might need a site router and when you might not.
Sorry - I made a mistake. Neither your change to ConsoleApplication nor Nicholas' suggestsions help. I still had by crude fix in libraries/src/Extension/Service/Provider/MVCFactory.php active :(
So its solved and we can close this? @GeraintEdwards
No its not solved @rdeutz without George's full fix from #38544
I'm not an expert with the new Container/DI system but at present, as far as I can see, there is now no way to avoid the SiteRouter object being instantiated when we try to boot the actionlogs component - this would be ok if we could set a dummy value for the uri.request ahead of time but this is not possible. The problem is within the loadSystemUris method of WebApplication since it always overwrites uri.request.
From my understanding George's PR at least provides a 'safe' default value for this that stops a crash.
When I get an opportunity I'll run some more tests of George's code and add some more observations.
Labels |
Added:
bug
|
There was a fix merged into 4.2 for this for cli apps using the joomla console. This PR once merged would make some of that functionality available for CLI Apps too #38544 (although would require support being added)
// cc @laoneo because technically this site router thing is causing a b/c issue (although it's not an incorrect change either)