diff --git a/core/lib/Drupal/Core/Config/Schema/SchemaCheckTrait.php b/core/lib/Drupal/Core/Config/Schema/SchemaCheckTrait.php index 435394936521dd39ad509ef5bdd4847d3e22d613..138e71d18df6956c15ed45e842d100eea70341c0 100644 --- a/core/lib/Drupal/Core/Config/Schema/SchemaCheckTrait.php +++ b/core/lib/Drupal/Core/Config/Schema/SchemaCheckTrait.php @@ -72,13 +72,35 @@ public function checkConfigSchema(TypedConfigManagerInterface $typed_config, $co fn (ConstraintViolation $v) => sprintf("[%s] %s", $v->getPropertyPath(), (string) $v->getMessage()), $filtered_violations ); - $errors = array_merge($errors, $validation_errors); + // If config validation errors are encountered for a contrib module, avoid + // failing the test (which would be too disruptive for the ecosystem), but + // trigger a deprecation notice instead. + if (!empty($validation_errors) && $this->isContribViolation()) { + @trigger_error(sprintf("The '%s' configuration contains validation errors. Invalid config is deprecated in drupal:10.2.0 and will be required to be valid in drupal:11.0.0. The following validation errors were found:\n\t\t- %s", + $config_name, + implode("\n\t\t- ", $validation_errors) + ), E_USER_DEPRECATED); + } + else { + $errors = array_merge($errors, $validation_errors); + } if (empty($errors)) { return TRUE; } return $errors; } + /** + * Whether the current test is for a contrib module. + * + * @return bool + */ + private function isContribViolation(): bool { + $test_file_name = (new \ReflectionClass($this))->getFileName(); + $root = dirname(__DIR__, 6); + return !str_starts_with($test_file_name, $root . DIRECTORY_SEPARATOR . 'core'); + } + /** * Helper method to check data type. *