Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
While working on REST module issues relating to error responses (and hence exception subscribers), I noticed this:
exception.default_json:
class: Drupal\Core\EventSubscriber\ExceptionJsonSubscriber
tags:
- { name: event_subscriber }
…
exception.custom_page_json:
class: Drupal\Core\EventSubscriber\ExceptionJsonSubscriber
tags:
- { name: event_subscriber }
arguments: ['@config.factory', '@path.alias_manager', '@http_kernel']
i.e. two services using the same class, with different arguments. The second one is never used, and has nonsensical arguments.
We can remove it.
Comment | File | Size | Author |
---|---|---|---|
#2 | 2833469-2.patch | 665 bytes | Wim Leers |
Comments
Comment #2
Wim LeersComment #3
Wim Leers#2323759: Modularize kernel exception handling introduced it.
Comment #4
tedbowI double checked that the string literal 'exception.custom_page_json' not found anywhere else in core except once in core.services.yml.
So the service is never used. RTBC!
Comment #6
alexpottWell it is not doing nothing... it means for every json exception we are firing \Drupal\Core\EventSubscriber\ExceptionJsonSubscriber::on400() etc twice :) to me this is a bug and we should backport this to 8.2.x since event listeners are not API and we're not stopping the thing from running. Nice find.
Committed 1c762d1 and pushed to 8.3.x. Thanks!
Leaving at rtbc aginst 8.2.x to discuss with the release managers.
Comment #7
alexpottDiscussed with @catch he pointed out that whilst code was indeed running twice - there's no bug caused by this and no real performance impact - so moving back to 8.3.x and setting fixed.