Skip to content
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

Access level delete, add tables names #39654

Closed
wants to merge 7 commits into from

Conversation

chmst
Copy link
Contributor

@chmst chmst commented Jan 17, 2023

Pull Request for Issue # .

Summary of Changes

An access level can only be delted if there is no content which uses this level. But there is no information given, which tabels are concerned.
This PR adds the list of tables to the error message.

Testing Instructions

Add an access level.
Set this access level for some items in your content, an article, a contact, a module .. whatever.
Then try to delete this access level.

Actual result BEFORE applying this Pull Request

You get a message
"You can't delete the view access level '%d:%s' because it is being used by content."

Expected result AFTER applying this Pull Request

grafik

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@joomla-cms-bot joomla-cms-bot added Language Change This is for Translators PR-4.3-dev labels Jan 17, 2023
@brianteeman
Copy link
Contributor

Nice idea. Not sure that the message is much more useful though as the table names are not very helpful. They give a clue to developers and those that speak english but otherwise they are pretty meaningless. Can it not display the component name? And cant see any benefit at all in displaying the id

@chmst
Copy link
Contributor Author

chmst commented Jan 17, 2023

@brianteeman totally agree with you. It is only useful for developers (I had to dive into the database when I wanted to delete an access level.
A good message would be "Please check your articles, use the access level filter. You can use the batch function to change the access level for all articles" and so on.

But I have no idea where to get he component. In Joomla I could use some hard coded table, but not for 3rd party extensions.

Every suggestion is appreciated.

Also agree with the id, will remove it from the message.

@brianteeman
Copy link
Contributor

I have tested this item ✅ successfully on 7832067

Does what it says so marking as successful

Still not sure how useful it is


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39654.

@brianteeman
Copy link
Contributor

I have tested this item 🔴 unsuccessfully on 7832067

Does what it says so marking as successful

Still not sure how useful it is


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39654.

@brianteeman
Copy link
Contributor

Steps to reproduce the issue

Create three access levels (1,2,3)
Create an article at level 2
Create a contact at level 3

Test 1

Select all three access and try to delete them

Expected result

Level 1 is deleted and an error message that I cannot delete 2 and 3 because they are in use

Actual result

image

Call stack

--
# | Function | Location
1 | () | JROOT\administrator\components\com_users\src\Model\LevelModel.php:123
2 | implode() | JROOT\administrator\components\com_users\src\Model\LevelModel.php:123
3 | Joomla\Component\Users\Administrator\Model\LevelModel->canDelete() | JROOT\libraries\src\MVC\Model\AdminModel.php:833
4 | Joomla\CMS\MVC\Model\AdminModel->delete() | JROOT\administrator\components\com_users\src\Controller\LevelController.php:116
5 | Joomla\Component\Users\Administrator\Controller\LevelController->delete() | JROOT\libraries\src\MVC\Controller\BaseController.php:672
6 | Joomla\CMS\MVC\Controller\BaseController->execute() | JROOT\libraries\src\Dispatcher\ComponentDispatcher.php:143
7 | Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch() | JROOT\libraries\src\Component\ComponentHelper.php:355
8 | Joomla\CMS\Component\ComponentHelper::renderComponent() | JROOT\libraries\src\Application\AdministratorApplication.php:143
9 | Joomla\CMS\Application\AdministratorApplication->dispatch() | JROOT\libraries\src\Application\AdministratorApplication.php:186
10 | Joomla\CMS\Application\AdministratorApplication->doExecute() | JROOT\libraries\src\Application\CMSApplication.php:294
11 | Joomla\CMS\Application\CMSApplication->execute() | JROOT\administrator\includes\app.php:61
12 | require_once() | JROOT\administrator\index.php:32

@chmst
Copy link
Contributor Author

chmst commented Jan 17, 2023

Thanks for testing - if more than one levels are to be deleted, it needs further work. This was already a bug before. Will change this PR to draft now.

@chmst chmst marked this pull request as draft January 17, 2023 10:10
@brianteeman
Copy link
Contributor

@chmst I created an issue for the multiple delete information
But I only got the error message with this PR

@chmst
Copy link
Contributor Author

chmst commented Jan 22, 2023

This needs to be resolved first (or together) #39654

Co-authored-by: ReLater <ReLater@users.noreply.github.com>
Co-authored-by: Quy <quy@nomonkeybiz.com>
@brianteeman
Copy link
Contributor

Another related issue is that you can save a view access level without assigning any user groups. In the case of the "special" level this will result in the admin of your site missing all the menus and toolbars and can only recovered by6 editing the database directly.

@Hackwar Hackwar added the Small A PR which only has a small change label Feb 25, 2023
@Hackwar Hackwar added the Feature label Apr 7, 2023
@HLeithner HLeithner changed the base branch from 4.3-dev to 5.0-dev May 8, 2023 15:02
@HLeithner
Copy link
Member

This pull request has been automatically rebased to 5.0-dev. No new features will be merged into Joomla! 4.3 series. Joomla! 4.4 series is a bridge release to make migration from Joomla! 4 to 5 as smooth as possible.

@HLeithner HLeithner changed the base branch from 5.0-dev to 5.1-dev September 30, 2023 22:50
@HLeithner
Copy link
Member

This pull request has been automatically rebased to 5.1-dev.

@webgras
Copy link
Contributor

webgras commented Oct 20, 2023

I ran in to that problem today, that I could not delete an access level.

I tested the patch on J5.0.0 successfully, as I could see which table was concerned.

In my case it was "#_fields", but it was not a com_content field, but a com_user field, that was still used with this access level. So, the error message with the table helped me a lot. Even if for a "normal" user the table info '#_fields' would not give sufficient information, because fields can be used in multiple areas. But an "experienced" user could have a look into the database and check. Also, a "normal" user would probably not have the rights to remove access levels.

So, the PR might not completely solve the problem (or create errors with multiple deletes), but it reduces the amount of time enormously.

I will test also for multiple and let you know.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39654.

@webgras
Copy link
Contributor

webgras commented Oct 20, 2023

If I delete two or more access level at the same time, then only the usages of one access level in the error message.

And shouldn't it be an error, not a warning?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39654.

@Hackwar
Copy link
Member

Hackwar commented Feb 21, 2024

Can you fix this for PBF?

@Hackwar Hackwar added the PBF Pizza, Bugs and Fun label Feb 21, 2024
@nadjak77
Copy link
Contributor

I have tested this item ✅ successfully on 56d67a5


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39654.

@chmst
Copy link
Contributor Author

chmst commented Feb 24, 2024

Needs some work - and is nort ready at the moment

@crimle
Copy link

crimle commented Feb 24, 2024

I have tested this item ✅ successfully on 2eec18c


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39654.

@chmst
Copy link
Contributor Author

chmst commented Apr 6, 2024

closing for a better solution. Pleas test #43223

@chmst chmst closed this Apr 6, 2024
@chmst chmst deleted the users-accesslevel-delete branch April 6, 2024 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Language Change This is for Translators PBF Pizza, Bugs and Fun PR-5.0-dev PR-5.1-dev Small A PR which only has a small change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet