Allow double JSON pointers in configuration files. #1854
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes a bug specific to PHP <7.3 in which configuration files cannot contain double JSON pointers (pointers to pointers). For example, if a configuration file
a.json
contains this:and
b.json
contains this:and
c.json
contains this:then running
Configuration::factory('a.json')
in PHP <7.3, the resulting object would be:instead of the desired:
The reason this bug is happening is due to the code in
Configuration::processKeyTransformers()
. A simpler piece of code that reproduces the bug is below.Pasting this code into https://3v4l.org/, choosing
+ include eol (slow)
, and clickingeval();
, it shows the different output for PHP <7.3 and PHP ≥7.3:Running the same code with some
var_export
s to see what is going on:it can be seen that in PHP ≥7.3, the
foreach
loops back over$obj
after it has been replaced by$value
, whereas in PHP <7.3 it does not:However, logically what we want to happen is that if
$obj
was replaced, it should immediately return instead of continuing to loop, i.e.:It can be seen that this produces the same desired result no matter the PHP ≥7 version:
This PR makes such a fix to the
processKeyTransformers()
method.Motivation and Context
This issue was noticed when adding the new OnDemand realm to ACCESS XDMoD. The PRs that add the OnDemand realm to ACCESS XDMoD (ubccr/xdmod-ondemand#50 and https://github.com/ubccr/xdmod-xsede/pull/473) use a configuration that uses the new
JsonReferenceWithFallbackTransformer
(introduced in #1852) which refers to a file (configuration/etl/etl_data.d/ood/request-path-filter.d/Texas-A&M-U-ACES-OnDemand.json
) that has a$ref-with-overwrite
to another file (configuration/etl/etl_data.d/ood/request-path-filter.json
).Tests performed
This PR extends an existing unit test to have it check for a double JSON pointer in a configuration file. I also tested ingesting logs on my port on
xdmod-dev
with the changes from ubccr/xdmod-ondemand#50, https://github.com/ubccr/xdmod-xsede/pull/473, and the PRs on which they depend.Checklist: