No Code Attached Yet
avatar PhocaCz
PhocaCz
3 Jul 2025

Steps to reproduce the issue

In Joomla 6 Alpha 2 these functions were removed:

public function getDispatcher()
protected function dispatchEvent(EventInterface $event)

from BaseDatabaseModel.php and from AbstractView.php
#45431

dispatchEvent function was marked as deprecated, everything OK here, but function getDispatcher() was not marked as deprecated - either in Joomla 5 nor in Joomla 6 Alpha 1

See IDE:

Image

Actual result

if some part depends on getDispatcher() from BaseDatabaseModel.php, it was removed.

System information (as much as possible)

Joomla 6 Alha 2

Example:

In J5 or J6Alpha1, if setDispatcher() is not set, it is automatically set in the BaseModel using the getDispatcher() function, which wasn't marked as deprecated.

To understand it correctly, setDispatcher() function should produce warning in Joomla 6 about deprecated using, but itself is not marked as deprecated.

The problem is, when the setDispatcher is not set, in Joomla 5 or Joomla 6 Alpha 1, it is set in BaseModel, in Joomla 6 Alpha 2 not more.

avatar PhocaCz PhocaCz - open - 3 Jul 2025
avatar joomla-cms-bot joomla-cms-bot - change - 3 Jul 2025
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 3 Jul 2025
avatar PhocaCz PhocaCz - change - 3 Jul 2025
The description was changed
avatar PhocaCz PhocaCz - edited - 3 Jul 2025
avatar PhocaCz PhocaCz - change - 3 Jul 2025
The description was changed
avatar PhocaCz PhocaCz - edited - 3 Jul 2025
avatar PhocaCz PhocaCz - change - 3 Jul 2025
The description was changed
avatar PhocaCz PhocaCz - edited - 3 Jul 2025
avatar PhocaCz PhocaCz - change - 3 Jul 2025
The description was changed
avatar PhocaCz PhocaCz - edited - 3 Jul 2025
avatar HLeithner
HLeithner - comment - 3 Jul 2025

As already discussed on mattermost.

Your implementation of MVCFactory doesn't execute $model->setDispatcher(); when creating the model.

$this->setDispatcherOnObject($model);

This has been deprecated in Joomla 4.4 while adding it as b/c code in #41371

In this line we throw a deprecation notice which says if you continue to use the code as you are an exception will be thrown starting with joomla 6 which is the case now.

sprintf('Dispatcher for %s should be set through MVC factory. It will throw an exception in 6.0', __CLASS__),

avatar rdeutz
rdeutz - comment - 3 Jul 2025

As said a couple of times already getDispatcher() is just moved to a trait in the event package https://github.com/joomla-framework/event/blob/4.x-dev/src/DispatcherAwareTrait.php

avatar PhocaCz
PhocaCz - comment - 3 Jul 2025

I understand, but this cannot be considered as a ‘move’ because the two methods are significantly different. The one in trait does not set the dispatcher if it does not exist, the one in BaseDatabaseModel does.

Again, this is a technical issue where it may happen that Joomla 5 extensions working without problem on Joomla 5 and Joomla 6 Alpha 1 will no longer work with or without Backward compatibility plugin, so at least this should be somehow addressed in the plugin.

I'm not addressing an ideological question here, about what is correct, how to load a component correctly, etc., I'm addressing a technical question. The difference between Joomla 5 (Joomla 6 Alpha 1) and Joomla 6 Alpha 2.

It just happened in reality that thanks to BaseDatabaseModel, which took care of the dispatcher when it didn't exist, everything worked, now it doesn't care anymore.

So the question is why the trait doesn't set the dispatcher if it doesn't exist. If the core component doesn't need it, nothing happens, this code is not executed, if it does, the dispatcher is set.

Add a Comment

Login with GitHub to post a comment