joomla-cms icon indicating copy to clipboard operation
joomla-cms copied to clipboard

Access level delete, add tables names

Open chmst opened this issue 2 years ago • 17 comments

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:

  • [x] No documentation changes for docs.joomla.org needed

  • [ ] Pull Request link for manual.joomla.org:

  • [x] No documentation changes for manual.joomla.org needed

chmst avatar Jan 17 '23 08:01 chmst

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

brianteeman avatar Jan 17 '23 08:01 brianteeman

@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.

chmst avatar Jan 17 '23 09:01 chmst

I have tested this item :white_check_mark: successfully on 7832067262b39a80733eb94116d75c81a6037513

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 avatar Jan 17 '23 09:01 brianteeman

I have tested this item :red_circle: unsuccessfully on 7832067262b39a80733eb94116d75c81a6037513

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 avatar Jan 17 '23 09:01 brianteeman

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

brianteeman avatar Jan 17 '23 09:01 brianteeman

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 avatar Jan 17 '23 10:01 chmst

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

brianteeman avatar Jan 17 '23 10:01 brianteeman

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

chmst avatar Jan 22 '23 08:01 chmst

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.

brianteeman avatar Feb 04 '23 19:02 brianteeman

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 avatar May 08 '23 15:05 HLeithner

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

HLeithner avatar Sep 30 '23 22:09 HLeithner

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 avatar Oct 20 '23 14:10 webgras

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.

webgras avatar Oct 20 '23 14:10 webgras

Can you fix this for PBF?

Hackwar avatar Feb 21 '24 07:02 Hackwar

I have tested this item :white_check_mark: successfully on 56d67a5aa8a22fd79b9f19db276b1949162ec3aa


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

nadjak77 avatar Feb 24 '24 10:02 nadjak77

Needs some work - and is nort ready at the moment

chmst avatar Feb 24 '24 11:02 chmst

I have tested this item :white_check_mark: successfully on 2eec18c0d74523f5d1f0326966d3261b292d9e9d


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

crimle avatar Feb 24 '24 11:02 crimle

closing for a better solution. Pleas test https://github.com/joomla/joomla-cms/pull/43223

chmst avatar Apr 06 '24 17:04 chmst