Problem/Motivation

BlockClassConfirmBulkOperationForm::getQuestion() returns $message_to_confirm, but the variable is only assigned inside the switch ($this->operation) branches and is never initialised. The block_class.confirm_bulk_operation route takes {operation} as a free URL parameter, so any value that matches no case reaches the return with the variable unset.

Steps to reproduce

  • Install Block Class 4.0.x-dev.
  • As a user with the administer block classes permission, visit:
/admin/config/content/block-class/confirm-bulk-operation/bogus_op/x/x/x/x/x/x

The page returns HTTP 200 and renders Warning: Undefined variable $message_to_confirm.

Proposed resolution

Initialise the variable before the switch, as already proposed in MR !5 on the closed issue #3279758:

public function getQuestion() {
  $message_to_confirm = "";

  switch ($this->operation) {

Worth considering as part of the same change: the insert case falls through without assigning a message, so a legitimate insert operation also returns an empty question.

Remaining tasks

  • Open a merge request against 4.0.x, crediting hswong3i for the original change in MR !5.
  • Review and test.

User interface changes

None, other than the PHP warning no longer being rendered on the confirmation page.

API changes

None.

Data model changes

None.

Comments

csakiistvan created an issue.