? PR-4.4-dev Pending

User tests: Successful: Unsuccessful:

avatar carlitorweb
carlitorweb
30 Dec 2022

Summary of Changes

This PR converts mod_articles_category to the new structure

Testing Instructions

  • Use Joomla 4.3
  • Create an instance of the module Articles Category. Note how it works.
  • Apply patch
  • Delete administrator/cache/autoload_psr4.php
  • Refresh the page, make sure the module still displays the same as before.
avatar joomla-cms-bot joomla-cms-bot - change - 30 Dec 2022
Category Modules Front End
avatar carlitorweb carlitorweb - open - 30 Dec 2022
avatar carlitorweb carlitorweb - change - 30 Dec 2022
Status New Pending
avatar carlitorweb carlitorweb - change - 30 Dec 2022
Labels Added: PR-4.3-dev
avatar richard67
richard67 - comment - 30 Dec 2022

@carlitorweb Unfortunately you have made the moving of the file and the changes inside the moved file with the same one commit, so GitHub does not show a moved and changed file but a deleted and a new file, so the history got lost. To avoid that, moving a file and changing its content have to be made with 2 separate commits. It’s not a big problem, but please remember that for future PR‘s.

avatar carlitorweb
carlitorweb - comment - 30 Dec 2022

@carlitorweb Unfortunately you have made the moving of the file and the changes inside the moved file with the same one commit, so GitHub does not show a moved and changed file but a deleted and a new file, so the history got lost. To avoid that, moving a file and changing its content have to be made with 2 separate commits. It’s not a big problem, but please remember that for future PR‘s.

Copy that. Really not notice this when doing the changes, sorry. If is neccessary I can do all again, not problem.

avatar richard67
richard67 - comment - 30 Dec 2022

If is neccessary I can do all again, not problem.

@carlitorweb Not necessary. All ok.

avatar laoneo
laoneo - comment - 31 Dec 2022

@richard67 sometimes, even when you rename a file and do a lot of changes, git is not able to detect the rename.

@carlitorweb thank you very much, now we need the two tests to get it merged.

avatar carlitorweb carlitorweb - change - 31 Dec 2022
Labels Added: Maintainers Checked
avatar carlitorweb
carlitorweb - comment - 31 Dec 2022

@laoneo you are welcome, glad to help. I will continue with the rest.

avatar ReLater
ReLater - comment - 31 Dec 2022

I don't know how "hungry" $db = $this->getDatabase(); is, but as far as I see $db is only used once. Maybe it's more efficient to move this->getDatabase down to the place where it's used (if it's used)?

                case 'random':
                    $articlesModel->setState('list.ordering', $this->getDatabase()->getQuery(true)->rand());
                    break;
avatar joomla-cms-bot joomla-cms-bot - change - 11 Mar 2023
Category Modules Front End Administration Modules Front End
avatar joomla-cms-bot joomla-cms-bot - change - 20 Mar 2023
Category Modules Front End Administration Modules Front End
avatar laoneo laoneo - change - 20 Mar 2023
Labels Added: PR-4.4-dev
Removed: PR-4.3-dev
avatar laoneo
laoneo - comment - 21 Mar 2023

Would it be possible to write also a system test for this module, similar as we did in #40092? If you need help how to get started with system tests, you can find some information here.

avatar laoneo
laoneo - comment - 21 Mar 2023

Can you also fix the code style issues?

avatar carlitorweb carlitorweb - change - 28 Mar 2023
Labels Added: ?
Removed: Maintainers Checked
avatar carlitorweb
carlitorweb - comment - 28 Mar 2023

@laoneo done, please check if is okay

After fix the others similar PRs I did, I will do what you mention about system test

avatar laoneo
laoneo - comment - 28 Mar 2023

As less functionality you change as better as the module should basically get converted only to the new structure. New features should be done in a separate pr on the 5.0-dev branch.

9d46bc6 29 Mar 2023 avatar carlitorweb cs
eeb0b18 29 Mar 2023 avatar carlitorweb cs
4f6760d 29 Mar 2023 avatar carlitorweb cs
avatar joomla-cms-bot joomla-cms-bot - change - 29 Mar 2023
Category Modules Front End Modules Front End JavaScript Unit Tests
avatar carlitorweb
carlitorweb - comment - 29 Mar 2023

@laoneo I added the cy test. I runned it, and it work. Let me kown if is okay like this for do it for the others PR

avatar carlitorweb carlitorweb - change - 29 Mar 2023
Labels Added: ?
avatar laoneo
laoneo - comment - 30 Mar 2023

@laoneo I added the cy test. I runned it, and it work. Let me kown if is okay like this for do it for the others PR

Nice, thank you very much!

avatar joomdonation
joomdonation - comment - 30 Mar 2023

Look like the cache implementation in this module is completely removed in this PR ?

avatar laoneo
laoneo - comment - 30 Mar 2023

It doesn't make sense to use a separate cache in a module as we have caching in the core which caches all modules.

avatar carlitorweb
carlitorweb - comment - 30 Mar 2023

It doesn't make sense to use a separate cache in a module as we have caching in the core which caches all modules.

Just curious, even 3rd party modules are cached?

avatar laoneo
laoneo - comment - 31 Mar 2023

Yes, when the module has a cache option, then it caches automatically according to the global cache option https://github.com/joomla/joomla-cms/blob/4.4-dev/libraries/src/Document/Renderer/Html/ModuleRenderer.php#L83.

avatar joomdonation
joomdonation - comment - 31 Mar 2023

It doesn't make sense to use a separate cache in a module as we have caching in the core which caches all modules

@laoneo We will have to be careful with this change. This module has Mode parameter. If set to Dynamic, Id of category will be get directly from request. If we use default cache from ModuleRenderer, the cachemode is static, cache key is not aware of this dynamic Category ID change and I think it won't work as expected.

In short, we will have to test and make sure it works properly when Mode parameter of the module set to Dynamic.

avatar laoneo
laoneo - comment - 31 Mar 2023

Thats why I would change as less logic as possible, because this pr is about converting and not somezhing else.

avatar joomdonation
joomdonation - comment - 31 Mar 2023

But this PR is not just converting to new structure, it also changes how it works and could be dangerous.

avatar carlitorweb
carlitorweb - comment - 31 Mar 2023

I will close the PR. Then make a new one later changing only the structure. Apologies for the problems.

avatar carlitorweb carlitorweb - change - 31 Mar 2023
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2023-03-31 15:44:09
Closed_By carlitorweb
Labels Removed: ?
avatar carlitorweb carlitorweb - close - 31 Mar 2023
avatar joomdonation
joomdonation - comment - 31 Mar 2023

@carlitorweb Thanks for working on this. This module, unfortunately, harder to convert than others which do not use Cache.

avatar carlitorweb
carlitorweb - comment - 31 Mar 2023

No, you are right. The cache will not work. I just remember I made a module for a project using the cache as I was doing here getting the article ID from a request, and I needed include the article ID in the cachekey for make it work properly.

Just saw the opportunity to try to change the module a bit, and I toke it. Anyway, is experience I got for others PR - not change nothing is not necessary to change.

avatar joomdonation
joomdonation - comment - 31 Mar 2023

Just saw the opportunity to try to change the module a bit, and I toke it

Better do it in separate PR so that it is easier to review :).

avatar laoneo
laoneo - comment - 1 Apr 2023

I would like to add this pr. Can you not just revert th3 breaking changes and reopen?

avatar carlitorweb carlitorweb - change - 1 Apr 2023
Status Closed New
Closed_Date 2023-03-31 15:44:09
Closed_By carlitorweb
avatar carlitorweb carlitorweb - change - 1 Apr 2023
Status New Pending
avatar carlitorweb carlitorweb - reopen - 1 Apr 2023
avatar carlitorweb
carlitorweb - comment - 1 Apr 2023

@laoneo here, I revert the helper and also added the group option you can find in https://github.com/joomla/joomla-cms/blob/338a9402a2702fa5d30bd16acf61138558bcf18f/modules/mod_articles_category/mod_articles_category.php

There is also the cache part but I did not included because not sure if is needed with what you wrote before about we have caching in the core which caches all modules. Remember, for the cache work properly in this module, in case of the dynamic mode need to know the article ID and use it for generate the cachekey

avatar joomdonation
joomdonation - comment - 2 Apr 2023

There is also the cache part but I did not included because not sure if is needed with what you wrote before about we have caching in the core which caches all modules

Just for information, yesterday, I tested a different PR related to cache and now I understand this better. This module has owncache parameter, not cache like other modules. So on the said line of code https://github.com/joomla/joomla-cms/blob/4.4-dev/libraries/src/Document/Renderer/Html/ModuleRenderer.php#L83, $params->get('cache', 0) == 1 returns false, it is not being cached by automatically by ModuleRenderer , and implement cache logic by it own

So we could not remove cache logic in this module. The same is applied to other modules which has owncache parameter. For these modules, it's output depends on certain variables from request, so it could not use static cache implementation from ModuleRenderer

avatar laoneo laoneo - change - 3 Apr 2023
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2023-04-03 14:04:10
Closed_By laoneo
avatar laoneo laoneo - close - 3 Apr 2023
avatar laoneo laoneo - merge - 3 Apr 2023
avatar joomdonation
joomdonation - comment - 3 Apr 2023

@laoneo Not sure why you merge this? The module cache feature is lost completely by this PR.

avatar laoneo
laoneo - comment - 3 Apr 2023

He reverted the cache code so the helper is as before. Why should something get lost now?

avatar carlitorweb
carlitorweb - comment - 3 Apr 2023

He reverted the cache code so the helper is as before. Why should something get lost now?

We meant this in our previous comments:

switch ($mode) {
case 'dynamic':
$option = $input->get('option');
$view = $input->get('view');
if ($option === 'com_content') {
switch ($view) {
case 'category':
case 'categories':
$idbase = $input->getInt('id');
break;
case 'article':
if ($params->get('show_on_article_page', 1)) {
$idbase = $input->getInt('catid');
}
break;
}
}
break;
default:
$idbase = $params->get('catid');
break;
}
$cacheid = md5(serialize([$idbase, $module->module, $module->id]));
$cacheparams = new \stdClass();
$cacheparams->cachemode = 'id';
$cacheparams->class = ArticlesCategoryHelper::class;
$cacheparams->method = 'getList';
$cacheparams->methodparams = $params;
$cacheparams->modeparams = $cacheid;

But I got confuse with your comment about the cache. But then @joomdonation comment about the cache should be included

avatar laoneo
laoneo - comment - 3 Apr 2023

Can you test #40316?

avatar carlitorweb
carlitorweb - comment - 3 Apr 2023

Can you test #40316?

I already did, is what I had wrote in case you said we needed include this

Add a Comment

Login with GitHub to post a comment