-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[4.0] Fix Modules Filter #33763
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.0] Fix Modules Filter #33763
Conversation
|
I have tested this item 🔴 unsuccessfully on 16f40f9 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33763. |
|
Ah, no. The fix is not this simple. I will see if I can find a solution |
|
Close this for now. When I come up with a solution, I will re-open. |
|
@sandramay0905 Could you please give it another try? |
|
I have tested this item ✅ successfully on f449246 Enabled on Admin language filtering: Filter on Persian and in site on english > works. Thanks @joomdonation This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33763. |
|
Unfortunately, the context is hard coded in some places. These would have to be adapted with this solution. One is here, for example:
If this is not changed, the following can happen:
|
|
@astridx Do you know if there are other places affected by this change? I ask because you tried to fix this issue before, so you have more experience and could help. |
|
@astridx Unless I'm mistaken, I think the issue you are talking about happens before this PR:
Something like (quick draft code, clean up needed) $app = Factory::getApplication();
$position = $app->getUserState('com_modules.modules.' . $clientId . '.filter.position');
if ($position)
{
$found = false;
// Add active position here
foreach ($options as $option)
{
if ($option->value ===$position)
{
$found = true;
break;
}
}
if (!$found)
{
$options[] = \JHtml::_('select.option', $position, $position);
}
}How do you think about it? |
|
I have tested this item ✅ successfully on ca23363 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33763. |
Now I'm not sure I understand you correctly. Without this PR, the error described in #33763 (comment) does not occur, right?
I don't know Joomla well. I searched for "com_modules.modules" and found this place:
But I don't know how important this is and I don't know if there are other places where the context might be put together with variables? |
Actually, that error happens because this PR. I explained the issue and proposed the solution in my earlier comment #33763 (comment). But I don't want to include that in this PR. I can make a new PR for that if needed.
=> That's not affected by the PR. It uses to auto-populate data when you create new module base on data from filter. For example, if you choose a Position in Modules Management page, that will be default position when you press New button to create a new module. That still works after this PR. |
|
@astridx Thinking more about the issue you described, I think after moving the modules to new position, we should set the position filter to that new position. That would be best solution, I think |
Actually, that is affected by this PR and fixed by this comment d47154e |
|
@sandramay0905 @ceford Could you please help testing it again? There is a new commit which auto-populate data for New Module base on data from filter (step #4 in testing instructions). Compare to your previous test, that new step is needed. The issue which @astridx mentioned is independent with this PR and I will make a new PR to fix it after this one merged (because the new code will depend on this PR) Thanks. |
|
I have tested this item ✅ successfully on d47154e This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33763. |
|
I have tested this item ✅ successfully on d47154e This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33763. |
|
Thanks @ceford and @sandramay0905 for testing. This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33763. |
|
Thanks astrid for finding possible issues. |
|
It is assumed that (array) should no longer be used, instead it should be [], there are many (array) in the whole Joomla 4 cms and they are still adding more, perhaps there is something that I do not know and justify the use of (array). Please tell me if I am in error and if not, change all the (array) to [] or at least not continue with that obsolete practice. |
|
@Stuartemk I don't understand your comment. Is this something related to this PR ? |
|
@Stuartemk Maybe you mix up type cast |
|
Maybe I'm confused, but I think this should be changed to be 100% compatible with php8 I think so, but I can be wrong $filters = (array) $app->getUserState('com_modules.modules.' . $clientId . '.filter'); for this $filters = [ ] $app->getUserState('com_modules.modules.' . $clientId . '.filter'); Regards |
|
@Stuartemk No, it's not valid syntax. For type casting, we will still have to use the original code: $filters = (array) $app->getUserState('com_modules.modules.' . $clientId . '.filter'); |
|
Nothing else than what I have said. |
|
Thank you! |



Pull Request for Issue #33692.
Summary of Changes
Currently, we use same session key for Admin and Site modules filter options value, thus causes unexpected behavior. One of the issue is #33692
There are other issues, too. For example, if you are on Site Modules and select a module position filter, then switch to Administrator, you won't see any modules... (because the system remember that site position, but of course, backend modules have different positions list. Same for module filter and menu item filter.
Testing Instructions