Install a system plugin which overrides the Joomla Jmenu class as described here:
Enable the system plugin Language Filter.
you would expect the custom plugin to be able to override the class as documented, like it worked for years.
since Joomla 3.4.0:
Fatal error: Cannot redeclare class JMenu in [the custom plugin]
any system plugin which is overriding Jmenu
Once a class is loaded, there is no overriding it; that is a PHP behavior that cannot be controlled (you would hit the same issue trying this with any of the application classes, JProfiler, and JSession; among others). In 3.4, JMenu is loaded by the plugin's constructor, and the plugin is explicitly imported by the application class before the first plugin event. So there is not a way to overload JMenu in the current code.
@mbabker yes after a class is already loaded, it can not be reloaded.
This method is documented here and has worked just fine for many years.
As of Joomla 3.4.0 the plugin 'system - Language Filter' loads the Jmenu class during its loading of the router on line 58. This changing behaviour of Joomla functionality is destroying functionality of 3rd party extensions.
Please consider setting the '$this->mode_sef' on line 59 is some other way which does not conflict.
No Code Attached Yet
|Status||New||⇒||Fixed in Code Base|
|Closed_Date||0000-00-00 00:00:00||⇒||2015-03-16 22:16:33|
|Closed_Date||0000-00-00 00:00:00||⇒||2015-03-16 22:16:34|
1) Instead of commenting on an issue that's been closed for over a year, you should be opening a new issue (and at least reference this one).
2) I did some checks the other day with the current 3.6 beta and the
JMenu class chain is NOT being loaded before the
onAfterInitialise event is dispatched. Actually the full list of loaded classes for a couple scenarios can be found at https://gist.github.com/mbabker/04dc4b6f2d1774352a99b9a4e45d9f75 so I'm going to suggest that something else is causing the menu classes to load.
3) Relying on overloading core classes is dangerous and shouldn't be considered as a long term option as it creates an unpredictable API for anyone using overloaded classes. I know there's a lot of infrastructure in core that is hardcoded to specific patterns, those need to be fixed and extension developers need to be trained to not overload the core API when those are fixed.