\Drupal\rest\Plugin\views\display\RestExport assumes view->getRequest() returns non-null; leads to fatal error during requestless executions like drush

Created on 25 June 2025, 2 days ago

Problem/Motivation

\Drupal\rest\Plugin\views\display\RestExport::initDisplay may be invoked during route rebuilding via cache clear. If this method is invoked without a request, via drush for example, this can cause a fatal error.

Call to a member function getRequestFormat() on null in Drupal\rest\Plugin\views\display\RestExport->initDisplay()

Steps to reproduce

* Create a rest export view with a path
* Rebuild cache via drush

Proposed resolution

* Do not assume the request exists

Remaining tasks

* Update initDisplay method to check for request existence before invoking methods on it.
* Update \Drupal\views\ViewExecutable::getRequest docblock @return statement to include null as a possible return value.
* Does the property \Drupal\views\ViewExecutable::$request need to be updated to explicitly allow null?

User interface changes

none

Introduced terminology

none

API changes

none

Data model changes

none

Release notes snippet

πŸ› Bug report
Status

Active

Version

11.2 πŸ”₯

Component

views.module

Created by

πŸ‡ΊπŸ‡ΈUnited States AaronBauman Philadelphia

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024