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

[5.0] Unable to delete user group #41906

Closed
HLeithner opened this issue Sep 24, 2023 · 5 comments
Closed

[5.0] Unable to delete user group #41906

HLeithner opened this issue Sep 24, 2023 · 5 comments

Comments

@HLeithner
Copy link
Member

Steps to reproduce the issue

delete a user group

Expected result

group gone

Actual result

0 Joomla\CMS\Event\Model\ModelEvent::setContext(): Argument #1 ($value) must be of type string, array given, called in /web/darmplus.verlauf.at/libraries/src/Event/AbstractEvent.php on line 205

Call stack
--
# | Function | Location
1 | () | JROOT/libraries/src/Event/Model/ModelEvent.php:75
2 | Joomla\CMS\Event\Model\ModelEvent->setContext() | JROOT/libraries/src/Event/AbstractEvent.php:205
3 | Joomla\CMS\Event\AbstractEvent->setArgument() | JROOT/libraries/src/Event/AbstractEvent.php:115
4 | Joomla\CMS\Event\AbstractEvent->__construct() | JROOT/libraries/src/Event/AbstractImmutableEvent.php:51
5 | Joomla\CMS\Event\AbstractImmutableEvent->__construct() | JROOT/libraries/src/Event/Model/ModelEvent.php:55
6 | Joomla\CMS\Event\Model\ModelEvent->__construct() | JROOT/libraries/src/Application/EventAware.php:106
7 | Joomla\CMS\Application\WebApplication->triggerEvent() | JROOT/administrator/components/com_users/src/Model/GroupModel.php:282
8 | Joomla\Component\Users\Administrator\Model\GroupModel->delete() | JROOT/libraries/src/MVC/Controller/AdminController.php:152
9 | Joomla\CMS\MVC\Controller\AdminController->delete() | JROOT/administrator/components/com_users/src/Controller/GroupsController.php:65
10 | Joomla\Component\Users\Administrator\Controller\GroupsController->delete() | JROOT/libraries/src/MVC/Controller/BaseController.php:730
11 | Joomla\CMS\MVC\Controller\BaseController->execute() | JROOT/libraries/src/Dispatcher/ComponentDispatcher.php:143
12 | Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch() | JROOT/libraries/src/Component/ComponentHelper.php:361
13 | Joomla\CMS\Component\ComponentHelper::renderComponent() | JROOT/libraries/src/Application/AdministratorApplication.php:150
14 | Joomla\CMS\Application\AdministratorApplication->dispatch() | JROOT/libraries/src/Application/AdministratorApplication.php:195
15 | Joomla\CMS\Application\AdministratorApplication->doExecute() | JROOT/libraries/src/Application/CMSApplication.php:306
16 | Joomla\CMS\Application\CMSApplication->execute() | JROOT/administrator/includes/app.php:58
17 | require_once() | JROOT/administrator/index.php:32
18 | require_once() | JROOT/public/administrator/index.php:16

System information (as much as possible)

5.0.0-beta2

Additional comments

@heelc29
Copy link
Contributor

heelc29 commented Sep 24, 2023

Something with the event mapping is wrong:

'onUserBeforeDeleteGroup' => Model\BeforeDeleteEvent::class,
'onUserAfterDeleteGroup' => Model\AfterDeleteEvent::class,

User\xxxDeleteEvent will work, but I'm not sure if this is the "right" event ...


Factory::getApplication()->triggerEvent($this->event_before_delete, [$table->getProperties()]);

Factory::getApplication()->triggerEvent($this->event_after_delete, [$table->getProperties(), true, $this->getError()]);

@Fedik
Copy link
Member

Fedik commented Sep 25, 2023

hm, this 2 events does not follow the parent implementation of delete() events:

$beforeDeleteEvent = new Model\BeforeDeleteEvent($this->event_before_delete, [
'context' => $context,
'subject' => $table,
]);

Almost all Model events requires context value, but here it is missing.
Addittionaly the subject argument required to be a Table object or object, but here it is an array.

@HLeithner
Copy link
Member Author

better to normalize it now?

@Fedik
Copy link
Member

Fedik commented Sep 25, 2023

it probably will be need own event class, because onUserAfterDeleteGroup

Factory::getApplication()->triggerEvent($this->event_after_delete, [$table->getProperties(), true, $this->getError()]);

Is very different from model onAfterDelete. It more like a copy/paste of onUserDeleteEvent, which have nothing to do with UserGroup.

The issue, that it wil make an incosistency, because onUserBeforeSaveGroup and onUserAfterSaveGroup is perfectly fit in to Model events,

@Fedik
Copy link
Member

Fedik commented Sep 25, 2023

Please test #41916

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants