-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[4.2] Introduce helper factory aware interface and convert news module to services #37445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4.2] Introduce helper factory aware interface and convert news module to services #37445
Conversation
9e16db4 to
01c9bc8
Compare
|
@laoneo please add a line in the xml like |
No module has such an element tag. Why should I add it? |
|
Because #33182 |
|
This should be enough 13c1cf6. #33182 is basically obsolete as it would already work without it, see here #36042 (comment). Just one entry needs a module attribute, doesn't mater which one. |
|
Where do you see that in action the element tag? None of my extensions does have that element and the code which uses any of the file elements is there since Joomla 1.7, which do extensions use since ages. Your pr was for 4, so I guess you added a new behavior. I wouldn't call the original way a hack. Anyway, lets open an issue where we can discuss this in more deep if you want to get that sorted. |
|
I think the project should have one unique way for defining the element especially for the namespaced extensions. When I did that PR (that was before your discovery?) I thought that normalising the |
|
Show me one extension which exists before Joomla 4 was released that uses the element tag. |
|
I can't, apart from the one I edited in that PR but maybe this Unit can: joomla-cms/tests/Unit/Libraries/Cms/Installer/Adapter/ModuleAdapterTest.php Lines 109 to 123 in 7c12dc7
|
|
Ok, we leave the pr as it is for now. |
|
in your commit you have created a new ArticleNews.php in the src/Helper directory. Asking because if that is the case, com_ajax is broken as it hardcoded looks for a module helperfile ending in 'Helper': so ArticleNewsHelper in this example. |
|
@Ruud68 you are right. Reverted to the original helper file and made it none abstract and added a new getArticles function which is none static. What do you think? On the other side also like this it still doesn't work with com_ajax, because the function needs to end with "Ajax" https://github.com/joomla/joomla-cms/blob/4.1-dev/components/com_ajax/ajax.php#L99. |
Cool, I think this will work. As for the Ajax in the function name that is not the issue. The issue was that the helperfile wasn't loaded. When that is loaded the method is called (ending in 'Ajax') so in the helper file you need to have that function otherwise you will get an error. This is only relevant if you have a module that will service com_ajax requests because they have functionality that relies on that (which the Joomla core modules do not do) What still 'bugs' me is that a module following this new approach will not work on J4.1 / 4.0. |
|
If you leave the old module file from J3 and load the helper the same way in the dispatcher as the quickicon module, then you have compatibility down to J3. |
|
@Ruud68 can you give this one here a test? |
|
@laoneo so just set up a new nightly 4.2 environment (april 5th), pulled this PR and copied the files over the new test environment. I get the message: RuntimeException: The file at mod_articles_news/helper.php does not exist. have not tried to troubleshoot this |
|
Did you add the function testAjax to the helper? |
|
Hi, that is not necessary. com_ajax first tries to load the helper and when it does then it tries to load the method. |
|
It does, but when the helper has no such function it tries the old way and when that doesn't succeed, it throws the old error message. You can see it here, it sets the result to |
|
sorry about that, you are completely right. |
|
I have tested this item ✅ successfully on b081abe This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37445. |
|
I have tested this item ✅ successfully on 3ee5c32 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37445. |
1 similar comment
|
I have tested this item ✅ successfully on 3ee5c32 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37445. |
|
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37445. |
|
Thanks everybody |

Pull Request for pr #37398.
Summary of Changes
Introduces a helper factory aware interface and converts the articles news site module to services. For backwards compatibility a new helper class was introduced and the old abstract one got deprecated.
Testing Instructions
Actual result BEFORE applying this Pull Request
It works.
Expected result AFTER applying this Pull Request
It works.