MediaWiki-extensions-CommunityConfiguration allows extensions to specify default values within the schema. For example, this is an excerpt from SuggestedEditsSchema in GrowthExperiments:
class SuggestedEditsSchema extends JsonSchema { public const link_recommendation = [ self::TYPE => self::TYPE_OBJECT, self::PROPERTIES => [ 'disabled' => [ self::TYPE => self::TYPE_BOOLEAN, self::DEFAULT => false, ], // [...] 'underlinkedWeight' => [ self::TYPE => self::TYPE_NUMBER, self::DEFAULT => LinkRecommendationTaskType::DEFAULT_SETTINGS[ LinkRecommendationTaskType::FIELD_UNDERLINKED_WEIGHT ], self::MINIMUM => 0, self::MAXIMUM => 1, ], 'minimumLinkScore' => [ self::TYPE => self::TYPE_NUMBER, self::DEFAULT => LinkRecommendationTaskType::DEFAULT_SETTINGS[ LinkRecommendationTaskType::FIELD_MIN_LINK_SCORE ], self::MINIMUM => 0, self::MAXIMUM => 1, ], // [...] ], ]; }
When the configuration is set to the following:
{ "link_recommendation": { "disabled": true } }
one would expect IConfigurationProvider::loadValidConfiguration() to return an array that would include all three properties. In this case, the call should return:
{ "link_recommendation": { "disabled": true, "underlinkedWeight": 0.5, "minimumLinkScore": 0.6 } }
However, this is not what happens. As of now, the code that merges the actual configuration and the defaults is not recursive (see DataProvider::enhanceConfigPreValidation). For this reason, the merging recognizes link_recommendation is already defined, and there is no attempt to merge the rest.
If we were working with arrays, array_merge_recursive would do what we want, but this method does not work with objects. Not sure how to do the same with stdClass, besides re-implementing it for objects.
