No Code Attached Yet
avatar Dekari
Dekari
15 Sep 2024

Steps to reproduce the issue

While processing a request (e.g. on a controller), if after some change on the framework (e.g. change language programatically) you need to refresh plugins language you can call "onAfterInitiliaze" event.

This will trigger languagefilter plugin also to ack the new language.

Expected result

languagefilter works with new language.

Actual result

languagefilter indeed works with new language but has "doubled" rules attached to the router.

This results in having 2 time "/en" language tag on sef urls.

System information (as much as possible)

Setting Value
PHP Built On Linux c19785.sgvps.net 6.6.21-MCIclouder470 #470 SMP PREEMPT_DYNAMIC Fri Mar 8 08:09:36 EET 2024 x86_64
Database Type mysql
Database Version 8.0.36-28
Database Collation utf8mb4_general_ci
Database Connection Collation utf8mb4_0900_ai_ci
Database Connection Encryption None
Database Server Supports Connection Encryption Yes
PHP Version 8.2.23
Web Server Apache
WebServer to PHP Interface cgi-fcgi
Joomla! Version Joomla! 4.4.8 Stable [ Pamoja ] 27-August-2024 16:00 GMT
User Agent Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36

Additional comments

Related function:
public function attachBuildRule(callable $callback, $stage = self::PROCESS_DURING)
{
if (!\array_key_exists('build' . $stage, $this->rules)) {
throw new \InvalidArgumentException(sprintf('The %s stage is not registered. (%s)', $stage, METHOD));
}

    $this->rules['build' . $stage][] = $callback;
}

Suggesting to "check if rule exists already, remove it and then re-apply it"

avatar Dekari Dekari - open - 15 Sep 2024
avatar Dekari Dekari - change - 15 Sep 2024
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 15 Sep 2024
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 15 Sep 2024
avatar Hackwar Hackwar - change - 19 Sep 2024
Status New Closed
Closed_Date 0000-00-00 00:00:00 2024-09-19 12:06:01
Closed_By Hackwar
avatar Hackwar Hackwar - close - 19 Sep 2024
avatar Hackwar
Hackwar - comment - 19 Sep 2024

The event onAfterInitialise can only be called once and can not be triggered a second time. This is also the case if you even only call the languagefilter plugins method. Whatever you are trying to do, this is not the way to go. This is not a bug in Joomla, thus closing this issue.

Add a Comment

Login with GitHub to post a comment