User tests: Successful: Unsuccessful:
Pull Request for Issue #37012 .
com_ajax tries to only load the module helper from the J3 module helper location
in browser goto: [yourdomain]/index.php?option=com_ajax&module=articles_news&method=test&format=raw
RuntimeException: The file at mod_articles_news/helper.php does not exist.
LogicException: Method testAjax does not exist.
Status | New | ⇒ | Pending |
Category | ⇒ | Front End com_ajax |
When you are on Joomla 4, then better to let the module implement Joomla\CMS\Helper\HelperFactoryInterface
. We want to avoid manual class name compiling. These ways are basically deprecated.
When you are on Joomla 4, then better to let the module implement
Joomla\CMS\Helper\HelperFactoryInterface
. We want to avoid manual class name compiling. These ways are basically deprecated.
can you point me to this in mod_articles_news as i use that as reference
You need to do the same as the quick icon module, convert it first to a service provider and then do the helper stuff.
okay... so that would basically mean that I have to redo all modules that use ajax. #snif (and probably someone has to refactor all Joomla core modules?)
Although 'deprecated' this PR improves at least the deprecated+++ thing where it is trying to load the helper file from the J3 location
and as a bonus: the module helper file was / is always an abstract class. so not only do you need to refactor the module into a service provider but also refactor the module helper file into not being abstract (as an abstract class cannot be instantiated). and by doing that potentially refactor / rethink everything that uses the helper class....
So now I start to understand why the module/helper.php 'workaround' is in there: it is way easier to not use the src/Helper/helper.php file but keep it in the J3 module helper location...
okay, so thanks @laoneo : refactoring the module into a service provider works.
but as this is not an option for some devs (probably adding to the 'lets wait until J5 is out before refactoring again') this PR would definitely add value for those developers who do not want their J4 module be refactored into a J3 file structure.
So if we get two testers (@arenamax @wedal looking at you :)), then one of the maintainers responsible for this code can decide to either accept or not accept. At least then we have some clarity on the effort to report the issue and the effort to propose a PR for it.
Ok so what's the gap we're trying to fill here? I'm missing something for sure I think.
If your J3 compatible your going to use the J3 file structure
If your J4 only your going to use namespaces and services.
I'm not seeing what scenario your solving by namespacing but not using services?
but as this is not an option for some devs (probably adding to the 'lets wait until J5 is out before refactoring again') this PR would definitely add value for those developers who do not want their J4 module be refactored into a J3 file structure.
That's one of the worst choices a developer can have, nobody should wait for J5, as now the gap is the smallest possible (and tbh if you programmed in a clean way in the past it's not that much of an effort to get a fully compatible J4 component...beside some renaming you mostly are deleting stuff, if you didn't programmed in a clean way, you shouldn't wait either but start now cleanup and refactor).
then one of the maintainers responsible for this code can decide to either accept or not accept.
I'm not in charge of 4.2 but for me this is a big "No" in terms of merging.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-03-31 12:42:12 |
Closed_By | ⇒ | chmst | |
Labels |
Added:
?
|
After reading the whole discussion and comments of maintainers I close this PR. Thanks all for your contributions and explanations!
Hi, thanks for the feedback and decision. please do not forget to re-open the issue again that was closed by this pr.
and as an advise: refactor the core joomla modules to the new namespacing / services as well as now only the administrator module quick-icons is correct. That is what started this issue in the beginning for me (using a core joomla module as boilerplate) and probably as well as for the issue starter.
Your pr started some important discussion in the Bug Squad chat. I will do tomorrow a pr where I convert a module for 4.2. It should act then as example for others. I would really appreciate when the outcome of this pr is a start of a process where we convert existing modules together.
Good morning @laoneo , will have a look over the weekend. First need to get a good understanding of how this works as there are more changes (like the dispatcher and dropping the mod_modulename.php then I currently have working on my new.module. I'm am assuming there is no documentation so need to dive into the code for this. Will follow up as soon as possible.
As for the actual work involved: maybe create an issue per module that needs refactoring so we / the devs can 'claim' that. Or use GitHub projects for that? Not sure what is handy ro have an overview and avail double work
@arenamax @wedal are you able to test this PR?