Skip to content

Registry is not the correct class for storing access rights#168

Merged
JLTRY merged 2 commits into
jmcameron:masterfrom
JLTRY:master
Nov 11, 2025
Merged

Registry is not the correct class for storing access rights#168
JLTRY merged 2 commits into
jmcameron:masterfrom
JLTRY:master

Conversation

@JLTRY

@JLTRY JLTRY commented Nov 10, 2025

Copy link
Copy Markdown
Collaborator

If we set
'core.edit','core.edit.state','core.edit.own' in a registry
only the core.state value is stored due to hierachical mechanism in Registry

If you first set 'core.edit' to true, it becomes $result['core']['edit'] = true. If you then set 'core.edit.state', it becomes $result['core']['edit']['state'] = true, but now $result['core']['edit'] would need to be an array, not a boolean.

If we set
'core.edit','core.edit.state','core.edit.own'
only the core.state value is stored due to hierachical mechanism in Registry

If you first set 'core.edit' to true, it becomes $result['core']['edit'] = true.
If you then set 'core.edit.state', it becomes $result['core']['edit']['state'] = true,
but now $result['core']['edit'] would need to be an array, not a boolean.
@JLTRY

JLTRY commented Nov 10, 2025

Copy link
Copy Markdown
Collaborator Author

@parapente it allows to correct one phpunit test testGetActionsSuperAdmin

@JLTRY

JLTRY commented Nov 10, 2025

Copy link
Copy Markdown
Collaborator Author

Note that under joomla 3.x the code was using a JObject

@parapente

parapente commented Nov 10, 2025

Copy link
Copy Markdown
Collaborator

You are right about the issue with the permissions. I noticed it too when I started the conversion of the tests.

The problem with the solution is that CMSObject is deprected since Joomla 4.3 and will be removed in Joomla 6. That is why I used a Registry Object as I think I found this type of conversion inside the CMS.

What I want to check is if those actions specified in the test are still valid. If they are then we need to find another solution (maybe a custom class).

@JLTRY

JLTRY commented Nov 10, 2025

Copy link
Copy Markdown
Collaborator Author

@parapente I propose to use ContentHelper::getActions('com_attachments');that will be updated in the future
$canDo1 = AttachmentsPermissions::getActions();
$canDo = ContentHelper::getActions('com_attachments');
`
image
compare with current implementation
image

@JLTRY

JLTRY commented Nov 10, 2025

Copy link
Copy Markdown
Collaborator Author

or we can use it in AttachmentsPermissions::getActions();
to we noticed that the CanDo class extends the Registry class with a null separator

@JLTRY

JLTRY commented Nov 10, 2025

Copy link
Copy Markdown
Collaborator Author

@parapente I update the PR with an other solution : use Registry with an empty separator

@parapente

Copy link
Copy Markdown
Collaborator

@JLTRY Much better! I didn't know Registry could be used without the seperator.

@JLTRY JLTRY merged commit 8e9566b into jmcameron:master Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants