Deprecate magic cancel submit handlers in views ui

Created on 16 July 2025, about 1 month ago

Problem/Motivation

ViewsUI::getStandardButtons adds has some magic to find cancel submit handlers, that looks for functions with the same name as the form id, with the suffix "_cancel".

The code looks like this, and has existed since at least views 6.x-2.x in contrib.

$cancel_submit = function_exists($form_id . '_cancel') ? $form_id . '_cancel' : [$this, 'standardCancel'];

But this is a relic to a time when forms exists in procedural functions in the global namespace. Forms now belong in their own classes, with submit handlers bundled in to the class. There are no _cancel functions left in core that are associated with forms.

There is a possibility existing contrib or custom modules are relying on this behaviour, but if these functions exist in .module files they will stop working once .module files are deprecated and removed. By deprecating now these can be updated to manually specify the submit handlers in the form class.

Steps to reproduce

$ grep -r "function .*_cancel(" core
core/modules/user/user.api.php:function hook_user_cancel($edit, UserInterface $account, $method): void {
core/modules/user/user.module:function user_cancel($edit, $uid, $method): void {
core/modules/user/user.module:function _user_cancel($edit, $account, $method): void {

Proposed resolution

Refactor $cancel_submit to throw a deprecation if the function_exists call finds something.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component

views_ui.module

Created by

πŸ‡¦πŸ‡ΊAustralia mstrelan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024