Problem/Motivation

`SplideAdmin::getOptionsetsByGroupOptions()` calls `Html::escape($splide->label())` without coercing the label to a string. Under PHP 8.1+, `Html::escape()` declares `string` for `$text`, so any `splide` optionset config entity whose `label` is `NULL` (or missing from the underlying config) triggers a fatal `TypeError`.

This breaks every admin form that calls `getOptionsetsByGroupOptions()` — most visibly `/admin/structure/block`, because the Splide block plugins enumerate optionsets to build their settings form.

TypeError: Drupal\Component\Utility\Html::escape(): Argument #1 ($text) must be of
type string, null given, called in .../splide/src/Form/SplideAdmin.php on line 474
in Drupal\Component\Utility\Html::escape() (line 433 of
core/lib/Drupal/Component/Utility/Html.php).

Steps to reproduce

1. Create or import a `splide.splide.*` config entity with `label: ~` (we hit this from a partial Slick→Splide migration; can also be reproduced by editing the exported YAML by hand and re-importing).
2. Visit `/admin/structure/block` (or any form that lists optionsets, e.g. a Splide field formatter settings page).
3. Page WSODs with the TypeError above.

Proposed resolution

Cast the label to `string` before escaping. This is defensive and behaviour-preserving for valid data, while letting the admin UI render an empty option (which is correctable through the normal optionset edit form) instead of crashing.
```php
$name = Html::escape((string) $splide->label());

Remaining tasks

Review patch
Add a unit/kernel test that covers a NULL-label optionset

Issue fork splide-3591430

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

charlie59 created an issue. See original summary.

tribekk made their first commit to this issue’s fork.

tribekk’s picture

Status: Active » Needs review

Opened MR !10.

This casts the optionset label before passing it to Html::escape() and adds a unit test for a NULL-label optionset.

Checked locally:
- php -l src/Form/SplideAdmin.php
- php -l tests/src/Unit/Form/SplideAdminUnitTest.php
- php -l over all project PHP files
- composer validate --no-check-publish
- git diff --check

composer install --no-interaction could not be completed in this module-only checkout because Composer does not have the Drupal package repository configured for drupal/blazy.

Credit to charlie59 for the original patches and reproduction.

tribekk’s picture

CI follow-up for the latest push.

composer, composer-lint, eslint, phpcs, and stylelint are passing now. The remaining failures look unrelated to this MR:
- phpstan reports existing unknown-class errors in src/Entity/Splide.php and tests/src/Kernel/SplideTextFormatterTest.php
- phpunit fails with Drupal\blazy\Utility\Type not found in existing tests

The PHPCS issue from my previous revision is fixed in the latest push.