Problem/Motivation

On the add entity queue and subqueue form pages we have error with PHP 8.1.

Error:

Deprecated function: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Component\Utility\Html::escape() (line 424 of core/lib/Drupal/Component/Utility/Html.php).

Steps to reproduce

  1. Install Drupal Core with PHP 8.1
  2. Install end enable the Entityqueue module
  3. Go to the Add Entityqueue page (/admin/structure/entityqueue/add)

You will see an error:

Deprecated function: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Component\Utility\Html::escape() (line 424 of core/lib/Drupal/Component/Utility/Html.php).

The same error if we want to add a subqueue for already existing entity queue, steps:

  1. Install Drupal Core with PHP 8.1
  2. Install end enable the Entityqueue module
  3. Go to the Add Entityqueue page (/admin/structure/entityqueue/add)
  4. Create a new queue for any entity but with the Multiple subqueues Queue type
  5. After, try to create a subqueue

Proposed resolution

Add additional check for titles where string arguments can be NULL.

Remaining tasks

[none]

User interface changes

[none]

API changes

[none]

Data model changes

[none]

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

tibezh created an issue. See original summary.

tibezh’s picture

Status: Active » Needs review
StatusFileSize
new1.47 KB

Here a patch.

Ruslan Piskarov made their first commit to this issue’s fork.

ruslan piskarov’s picture

Also fixed a fatal error: count(): Argument #1 ($value) must be of type Countable|array, null given in count() .

  • amateescu committed 3712a20 on 8.x-1.x
    Issue #3298778 by Ruslan Piskarov, tibezh: PHP 8.1 Deprecated function:...
amateescu’s picture

Status: Needs review » Fixed
StatusFileSize
new4.1 KB

Thanks for opening this issue and for the patches! I tweaked the fixes a bit and committed the patch attached.

Status: Fixed » Closed (fixed)

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