Problem/Motivation
I noticed this issue when installing commerce_payment on the 11.x branch.
While discovering block plugin classes it tries to create a Reflection of the \Drupal\commerce_product\Plugin\Block\VariationFieldBlock.
VariationFieldBlock extends a FieldBlock class from the layout_builder module (which is not required for commerce_payment and in that case is not installed). While trying to create \ReflectionClass of it, the autoloader will start including that file and will fail due to FieldBlock not being included since layout_builder is not installed.
After that whole site will be down due to that critical error.
Steps to reproduce
- Clean install dev branch
- Install commerce_payment
- See "Unexpected error" on every page
Proposed resolution
Surrounding web/core/lib/Drupal/Component/Plugin/Discovery/AttributeClassDiscovery.php:125 with try/catch seems to help, not sure if it is the right solution though.
I tried to add a test to \Drupal\Tests\Component\Plugin\Attribute\AttributeClassDiscoveryTest but to test this bug we need an autoloader, otherwise include_once will fail instantly.