Problem/Motivation
config/schema/commerce_license.schema.yml declares commerce_product.commerce_product_variation_type.*.third_party.commerce_license:license_types as a
sequence without a sequence: item definition, so every value saved in it has no schema.
The variation type form stores the allowed license types keyed by plugin ID, e.g. license_types: { role: role }. Strict config schema checking, as used by
KernelTestBase and BrowserTestBase, then fails:
Drupal\Core\Config\Schema\SchemaIncompleteException: Schema errors for commerce_product.commerce_product_variation_type.license with the following errors: commerce_product.commerce_product_variation_type.license:third_party_settings.commerce_license.license_types.role missing schema
This affects any test that installs config for a licensable variation type, including recipes that ship one. The module's own tests do not catch it because none of them sets
license_types. Similar to #3521592: third_party_settings.commerce_license.interval.interval doesn't exist, which fixed the same kind of gap for interval.
Steps to reproduce
Run this Kernel test (tests/src/Kernel/ProductVariationTypeSchemaTest.php):
namespace Drupal\Tests\commerce_license\Kernel; use Drupal\commerce_product\Entity\ProductVariationType; use Drupal\Tests\commerce_order\Kernel\OrderKernelTestBase; /** * Tests the schema of the license settings on product variation types. * * @group commerce_license */ class ProductVariationTypeSchemaTest extends OrderKernelTestBase { /** * {@inheritdoc} */ protected static $modules = [ 'commerce_license', ]; /** * Tests that the allowed license types are covered by the config schema. */ public function testLicenseTypesSchema(): void { $variation_type = ProductVariationType::create([ 'id' => 'license', 'label' => 'License', 'orderItemType' => 'default', 'traits' => ['commerce_license'], ]); $variation_type->setThirdPartySetting('commerce_license', 'license_types', ['role' => 'role']); $variation_type->setThirdPartySetting('commerce_license', 'activate_on_place', TRUE); $variation_type->save(); $this->assertSame( ['role' => 'role'], ProductVariationType::load('license')->getThirdPartySetting('commerce_license', 'license_types'), ); } }
It fails with the exception above on 3.0.2 and on 3.x.
Proposed resolution
Give the sequence an item type:
license_types: type: sequence label: 'License types allowed with this product variation' sequence: type: string label: 'License type'
With this change the test passes.
Remaining tasks
- MR with the schema fix and the test.
- Review.
User interface changes
None.
API changes
None.
Data model changes
Config schema only: license_types items are typed as strings. No stored data changes.
Issue fork commerce_license-3627738
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
zaporylieMR is open, ready for review
Comment #4
zaporylieComment #6
jsacksick commented