Updated: Comment #6

Problem/Motivation

user_cancel_methods() defines several methods for canceling a user account.
There is no info hook, but there is an alter.
This would imply that allow a module to provide its own methods, but they cannot as these are then checked in _user_cancel(), and actual code is run from there only.

These constitute a good chunk of procedural code left in user.module, and in issues like #1946466: Convert all confirm_form() in user.module and user.pages.inc to the new form interface and convert route, they are called from within a class.

Proposed resolution

Provide a UserCancellation plugin type

Remaining tasks

Decide if this is a good idea

User interface changes

N/A

API changes

This could potentially be done with no API break. It would be a pure API addition

Original report by @tim.plunkett

#1946466: Convert all confirm_form() in user.module and user.pages.inc to the new form interface and convert route moves user_cancel_methods() from user.pages.inc to user.module, but we need a better solution.

catch jokingly suggested plugins, but that's not as crazy as it sounds.
It's essentially an info hook, it has an alter, and _user_cancel() provides functionality for each of the different methods.

Comments

Crell’s picture

Weird as it sounds, either plugins or a chain-of-responsibility set of services seem like a decent fit in the new model. As Tim notes, it's badly implemented info hook with one method for each thingie defined. The one caveat is that plugins, AFAIK, assumes you will be instantiating something. There's really nothing to configure/instantiate here, is there? It's a global setting, and we've not been using plugins for most of those, just services and a facade object.

tim.plunkett’s picture

If we moved it to proper plugins, contrib could provide new ways to cancel an account, or tweak/replace existing ones.

dawehner’s picture

As far as I understand you currenlty extend the behavior by implement hook_user_cancel_methods_alter and hook_user_cancel

This will be replaced by a plugin system which can register new items in the batch and then call arbitrary methods while running the batch. A service based approach seems not really needed.

Crell’s picture

dawehner: I usually argue that a plugins approach is not needed, as the service-based one has fewer moving parts. :-) But more to the point, does the lack of instantiation mean it doesn't fit the Plugins model?

dawehner’s picture

I personally think that a service matches everything you want to be able to reuse a certain component in potential multiple places which is probably not the case for user cancel?

tim.plunkett’s picture

Issue tags: +API change, +Plugin system

I think instantiation will be needed? Each of those methods corresponds to some functional code in _user_cancel(), those would be a method on the class...

I will update the issue summary, but I'm not jumping into coding this until it has more committer feedback.

tim.plunkett’s picture

Issue summary: View changes

Updated

tim.plunkett’s picture

Assigned: Unassigned » tim.plunkett
Issue summary: View changes
tim.plunkett’s picture

Version: 8.0.x-dev » 8.1.x-dev
Assigned: tim.plunkett » Unassigned

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

joachim’s picture

> But more to the point, does the lack of instantiation mean it doesn't fit the Plugins model?

One case for plugins is that the user cancellation methods are something that need to be listed and selectable in the admin UI.

> I will update the issue summary, but I'm not jumping into coding this until it has more committer feedback.

Tagging for that.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

andypost’s picture

phenaproxima’s picture

Status: Active » Closed (duplicate)

I agree that this can be closed out. Since this issue predates Drupal 8.0.0, but never really got off the ground, I'm not going to bother transferring credit (but happy to do that if someone feels it would be appropriate).