Directory

⚓ T363412 Community configuration: Add support to JSON Schema dynamic defaults
Page MenuHomePhabricator

Community configuration: Add support to JSON Schema dynamic defaults
Closed, ResolvedPublic

Description

MediaWiki-extensions-CommunityConfiguration has a support for dynamicDefault, which allow to create a default for a schema using a callback, rather than as a PHP constant. This is occassionally needed to workaround PHP language limitations. For example, it is impossible to set an empty object as a default using the standard JsonSchema::DEFAULT approach, because:

self::DEFAULT => [
 (object)[],
]

is not valid PHP code (Constant expression contains invalid operations).

To be able to use empty objects as JSON defaults, we would need support for dynamic defaults. Dynamic defaults would be also useful for conditional fallbacks.

Acceptance Criteria
  • When JSON Schema specifies a dynamic default using a format understood by ReflectionSchemaSource (the dynamicDefault keyword), JsonSchemaBuilder evaluates the dynamic default.
  • When both a dynamic and static default is specified, the dynamic default should take precedence.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change #1027158 had a related patch set uploaded (by Urbanecm; author: Urbanecm):

[mediawiki/extensions/CommunityConfiguration@master] Support dynamic defaults

https://gerrit.wikimedia.org/r/1027158

Change #1027158 merged by jenkins-bot:

[mediawiki/extensions/CommunityConfiguration@master] Support dynamic defaults

https://gerrit.wikimedia.org/r/1027158

Moved from sprint to sprint a couple of times, resolving.