Skip to content

DataProducerExecutionTrait::executeDataProducer() ignores defined default values #1233

@pmelab

Description

@pmelab

@pmelab @klausi I guess this is out of scope, but there seems to be an issue with the data producer argument default values.

For example, the entity_reference plugin definition sets a default value for access argument:

* "access" = @ContextDefinition("boolean",
* label = @Translation("Check access"),
* required = FALSE,
* default_value = TRUE
* ),

So I would guess that the resolve method never gets null for $access argument. Right?

However, it is typehinted as ?bool:

public function resolve(EntityInterface $entity, $field, ?string $language, ?array $bundles, ?bool $access, ?AccountInterface $accessUser, ?string $accessOperation, FieldContext $context) {

Then, when we call DataProducerExecutionTrait::executeDataProducer() without providing access argument, the data producer receives access as null. So it does not check the access, even if this should be the default behavior.

I would suggest:

  • Remove ? from data producer arguments having default values.
  • Improve DataProducerExecutionTrait::executeDataProducer() to fill in default argument values.

Originally posted by @Leksat in #1232 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions