- Issue created by @sarahwylie
- πΊπΈUnited States agentrickard Georgia (US)
The problem here, I suspect, goes much deeper. The current implementation of SDC doesn't do any testing against core render components, which can be wildly inconsistent depending on how they are passed to the template.
So the component assumes that breadcrumb.[0].title is a string, but that is not a safe assumption. How do we make it so?
Or is the intent of SDC not to render core templates but only custom data that the theme/module completely controls?
- Status changed to Needs work
7 months ago 5:57pm 15 April 2024 - πΊπΈUnited States agentrickard Georgia (US)
This may have been corrected when SDC merged to core, since this seems to be new:
// Dismiss type errors if the prop received a render array. $errors = array_filter( $validator->getErrors(), function (array $error) use ($context): bool { if (($error['constraint'] ?? '') !== 'type') { return TRUE; } return !Element::isRenderArray($context[$error['property']] ?? NULL); } ); if (empty($errors)) { return TRUE; }
- πΊπΈUnited States agentrickard Georgia (US)
Updated title.
This issue has been fixed -- sort of -- in 10.3. However, the
enforce_prop_schemas
value in a theme.info.yml file only applies if NO schema is present for the component.Individual validation errors are still thrown if one part of the schema is incorrect.
$schema = $component->metadata->schema; if (!$schema) { if ($component->metadata->mandatorySchemas) { throw new InvalidComponentException(sprintf('The component "%s" does not provide schema information. Schema definitions are mandatory for components declared in modules. For components declared in themes, schema definitions are only mandatory if the "enforce_prop_schemas" key is set to "true" in the theme info file.', $component_id)); } return TRUE; }
As a developer, I would expect the final exception to be wrapped in a similar statement.
if ($component->metadata->mandatorySchemas) { throw new InvalidComponentException($message); }
- Status changed to Active
7 months ago 8:18pm 16 April 2024 - e0ipso Can Picafort
enforce_prop_schemas
is only used to make sure components in the theme contain a valid schema. It is not meant as an on/off switch for schema validation.As I see it, if you don't want schema validation, there are two solutions:
- Delete the prop schemas, and set
enforce_prop_schemas: false
- Keep the invalid schemas, and turn off PHP assertions.
@agentrickard any chance you can write a note in the SDC documentation on this topic β to avoid other tripping over this? Right now docs are a bit bare bones and could use some love. See screenshot below.
- Delete the prop schemas, and set
- πΊπΈUnited States agentrickard Georgia (US)
Well, except we are trying to use a theme that does have schema validation. The theory makes sense but I'd still love to see a setting that would not trigger a fatal render error.
I see those as breaking changes (deprecations) that have no advance warning, since they can come from the fact that current theming doesn't enforce strict typing and SDC does.
It may be that the plan is to correct all that for Drupal 11, but as it stands, SDC may break randomly when modules are installed.
Note: I will update the docs, too.
- Status changed to Closed: works as designed
7 months ago 2:45pm 17 April 2024 - πΊπΈUnited States agentrickard Georgia (US)
We're going to close this as part of the development plan to "catch errors early". See π± [Policy] SDC backwards compatibility policy Active . specifically the note "To determine if this policy is feasible, it would be worth SDC-ifiying some core components that would benefit from better default styles."
New ticket for the breadcrumb issue: π SDC: Breadcrumb handling consistency Active