Allow NULL default values in @Plugin annotations

Created on 26 April 2013, about 11 years ago
Updated 4 February 2023, over 1 year ago

Problem/Motivation

Right now properties defined in annotations are discarding default values that are set to NULL. In other representations of data (PHP, YAML) we support NULLs. There's no reason not to support NULL while Doctrine handles NULL values.

Proposed resolution

Remove NULL filtering from \Drupal\Component\Annotation\Plugin to allow NULL in annotation default values. Supported in #12 πŸ› Allow NULL default values in @Plugin annotations Needs work

Remaining tasks

Review
Commit

User interface changes

None.

API changes

Developers are able to assign NULL to annotation defaults.

Data model changes

NULL available in annotation default values.

Beta phase evaluation

<!--Uncomment the relevant rows for the issue. -->
πŸ› Bug report
Status

Needs work

Version

10.1 ✨

Component
PluginΒ  β†’

Last updated about 18 hours ago

Created by

πŸ‡¬πŸ‡§United Kingdom Xano Southampton

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request β†’ as a guide.

    Didn't see a test patch so running locally

    d6/FieldDiscoveryTest

    Failed asserting that two arrays are identical.
    

    d7/FieldDiscoveryTest

    Failed asserting that two arrays are identical.
    

    PluginTest actually passes. (not sure an issue)

    Reviewing the fix

    -    // Only keep actual default values by ignoring NULL values.
    -    $defaults = array_filter($reflection->getDefaultProperties(), function ($value) {
    -      return $value !== NULL;
    -    });
    +    $defaults = $reflection->getDefaultProperties();
    +    unset($defaults['definition']);
    

    Appears to be doing what the IS states.

    Looks good to me.

  • Status changed to Needs work over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States tim.plunkett Philadelphia

    PluginTest failing without the fix is a blocker IMO. The other two are test tweaks needed to adapt to this change, but the unit test for this code should absolutely cover this.

Production build 0.69.0 2024