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:
if some part depends on getDispatcher() from BaseDatabaseModel.php, it was removed.
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.
Labels |
Added:
No Code Attached Yet
|
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
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.
As already discussed on mattermost.
Your implementation of MVCFactory doesn't execute
$model->setDispatcher();
when creating the model.joomla-cms/libraries/src/MVC/Factory/MVCFactory.php
Line 164 in 8868adc
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.
joomla-cms/libraries/src/MVC/Controller/BaseController.php
Line 1101 in 8849898