WSOD on config page if field_ui is not enabled

Created on 25 March 2023, over 1 year ago

Problem/Motivation

While testing πŸ“Œ Fix the issues reported by phpcs Needs review with the Minimal installation profile, I noticed that the configuration page /admin/structure/paragraphs_type/ptoc generated a WSOD. This is because the Minimal profile does not enable the field_ui module.

Steps to reproduce

  1. Install Drupal with the minimal installation profile.
  2. Enable the ptoc module and its dependencies.
  3. Visit /admin/structure/paragraphs_type/ptoc.

The result is a WSOD, with this error in the logs:

Symfony\Component\Routing\Exception\RouteNotFoundException: Route "entity.entity_view_display.paragraph.view_mode" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 206 of /var/www/html/core/lib/Drupal/Core/Routing/RouteProvider.php).

Proposed resolution

Some sites do not enable the field_ui module on production, so adding that as a dependency is not a good option.

The code in PtocConfigForm::buildForm() should check that the route exists before generating the URL:

          $url = Url::fromRoute('entity.entity_view_display.paragraph.view_mode', [
            'paragraphs_type' => $bundle,
            'view_mode_name' => 'ptoc',
          ]);

Remaining tasks

User interface changes

No WSOD when field_ui is not enabled.

API changes

None

Data model changes

None

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States benjifisher Boston area

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

Comments & Activities

Production build 0.71.5 2024