AutowireTrait and autowire for services behave differently for nullable types

Created on 29 July 2024, 4 months ago

Problem/Motivation

Hello, When using AutowireTrait and the autowire option for services, you will get different behavior if the service does not exist and the parameter is nullable:

  1. For services, you will be left with null
  2. When using AutowireTrait, you will get an exception about the service not existing.

I think this is a problem because I expect the two options to behave as similarly as possible.

Steps to reproduce

  1. Create a controller that accepts a service from another module as optional, and leave the other module disabled.
  2. Try to instantiate the controller

Proposed resolution

Check if the parameter is nullable, if so then skip throwing an exception if the service does not exist and set the argument to null.

Remaining tasks

  1. Test coverage.

User interface changes

None.

Introduced terminology

None.

API changes

Data model changes

None.

Release notes snippet

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
BaseΒ  β†’

Last updated about 1 hour ago

Created by

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024