Problem/Motivation

When using PHP 8.1, I am getting this error when on this page /admin/config/system/mailer/policy/add:
Warning: Undefined array key "sub_type" in Drupal\symfony_mailer\Form\PolicyAddForm->form() (line 49 of modules/contrib/symfony_mailer/src/Form/PolicyAddForm.php).

Steps to reproduce

Navigate to /admin/config/system/mailer/policy/add while using PHP 8.1

Proposed resolution

Replace:
if (!$definition['sub_type']) {
With:
if (!isset($definition['sub_type'])) {

Comments

jaydee1818 created an issue. See original summary.

jaydee1818’s picture

StatusFileSize
new537 bytes

Here's a patch that does the trick.

jaydee1818’s picture

StatusFileSize
new538 bytes

Take two - here's a patch that does the trick.

sakthi_dev’s picture

Status: Active » Needs review
StatusFileSize
new1.94 KB
new1.63 KB

Created patch to resolve deprecated function. Please review.

The last submitted patch, 4: sub-type-test-fails-4.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

adamps’s picture

Title: PHP 8.1 error Undefined array key "sub_type" PolicyAddForm.php » Undefined array key "sub_type" in PolicyAddForm.php

Thanks for the report. I see it on PHP 8 so it's not only PHP 8.1.

adamps’s picture

adamps’s picture

The bug is that the sub_type key is missing. I believe this is the right patch.

The tests are broken on PHP8.2 so that needs fixing separately.

  • AdamPS committed bd56521b on 1.x
    Issue #3355536 by jaydee1818, sakthi_dev, AdamPS: Undefined array key "...
adamps’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.