As as result I can now override/extend any class I like with minimal effort.
It was far too easy to do though, so I'm suspicious as to why it's not been implemented yet - there's no way I'm the first to have thought of this. Is there a reason that plugins are unable to be used until an application object has been created, or can it really be as simple as 'because nobody's done it yet'?
--
You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-cms+unsubscribe@googlegroups.com.
To post to this group, send email to joomla-dev-cms@googlegroups.com.
Visit this group at https://groups.google.com/group/joomla-dev-cms.
For more options, visit https://groups.google.com/d/optout.
There is an inner coupling with JPluginHelper's method to load the plugins to a JUser object fetched from JFactory, which will first look for the user object from the session (inherently starting the session).
Nor do I think we should have an event that makes it possible to overload the application objects (the CMS is already too fragile with having untyped dependencies to JApplicationCms
Why aren't you using a self-defined defines.php?
On Sunday, November 20, 2016 at 6:22:11 PM UTC, Michael Babker wrote:There is an inner coupling with JPluginHelper's method to load the plugins to a JUser object fetched from JFactory, which will first look for the user object from the session (inherently starting the session).
That's actually incorrect - a session object is created, it isn't doesn't actually try to start a session until halfway through the `loadSession` method during construction of the application object.
Nor do I think we should have an event that makes it possible to overload the application objects (the CMS is already too fragile with having untyped dependencies to JApplicationCms
This is what I was wondering about. My follow up question to it is asked purely for my own education rather than questioning the rational of that decision - why?
I can understand that by overriding it you are seriously, heavily able to mess with the guts of the CMS. Misuse of it will undoubtedly lead to a whole load of problems. Why, though, is that any worse than messing up anything else? I can already write a crap component that exposes any site using it to every two-bit script-kiddie going, so is it really that much more of a problem if I poorly implement an application class? Surely it's a dev's responsibility to ensure their code works properly? Or is it a case that when working within a framework some things should be left inviolable?
I doubt that there are more than 5 sites out there that would benefit
from something like that.
My issue with overloading classes (that is, you using a custom version of JApplicationSite by messing with the autoloader or PHP behaviors to get your custom version loaded before the correct version) is it no longer makes the API consistent. This is nothing against Peter and his products, but one of the ways Advanced Module Manager works is by overloading the JModuleHelper class. So now on sites using that extension, if there is a bug with a stack trace leading back to that class, now you have to spend extra time figuring out whether it is a bug in the overloaded class or with Joomla core (since IIRC the majority of that class is based on the core code but a couple of the methods have some extra code for his extension to work). As an extension developer, I can't rely on the API to be correct when these classes are overloaded. It's not just the app class or JModuleHelper, but at least with the module helper this was the easiest current example I could reference.