Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config): Add missing handling for envCache in getKeys() #46140

Merged
merged 4 commits into from
Sep 16, 2024

Conversation

joshtrichards
Copy link
Member

@joshtrichards joshtrichards commented Jun 26, 2024

Context: #3966

Summary

NC_ environment variable config.php overrides were not appearing in the output of occ config:list system nor occ config:system:get xxx. This was creating nearly impossible to diagnose configuration/ behavior discrepancies.

getValue() was already, of course, returning NC_ provided config values. But getKeys() was not due to (a) it having no handling for the envCache; (b) all values in envCache being saved under NC_ keys rather than their actual config keys (which needed additional handling to be merged with the non-NC_ keys).

  • Refactored readData() so that:
    • we aren't saving the entire environment in the envCache anymore (only those prefixed NC_)
    • we save NC_ provided config values in the envCache under their real configuration key
  • Refactored getValue() to accommodate readData() refactor
  • Fixed getKeys() to now return envCache keys as well in order to be consistent with getValue() (in turn, addressing the underlying bugs noted in the opening paragraph)

Result:

  • Environment provided config variables now appear in occ config:list system as expected.
  • Environment provided config variables now appear when queried via occ config:system:get blah
  • envCache is now free of non-NC related environment variables

TODO

  • Update/add tests (looking now)

Checklist

@joshtrichards joshtrichards added bug 3. to review Waiting for reviews ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring) labels Jun 26, 2024
@joshtrichards joshtrichards added this to the Nextcloud 30 milestone Jun 26, 2024
@joshtrichards joshtrichards marked this pull request as ready for review June 26, 2024 14:45
@joshtrichards
Copy link
Member Author

/backport to stable29

@joshtrichards
Copy link
Member Author

/backport to stable28

@joshtrichards
Copy link
Member Author

Cypress test seems unrelated (but not the usual "just re-run it" Cypress test failure either).

lib/private/Config.php Outdated Show resolved Hide resolved
@joshtrichards joshtrichards force-pushed the fix-nc-env-inclusion branch 2 times, most recently from 91a5264 to da697ea Compare June 27, 2024 15:06
NC_ env variable overrides were not appearing in
the output of `occ config:list system` nor `occ
config:system:get xxx`. This was creating nearly
impossible to diagnose configuration/ behavior
disprepancies.

- Refactored readData() so that we aren't saving
  the entire environment in the envCache anymore
  (only those prefixed "NC_") and so that we save
  NC_ provided config values under their real
  key.
- Refactored getValue() to accommodate readData()
  refactor
- Fixed getKeys() to properly return
  envCache keys too

Environment provided config variables now appear
in `occ config:list system` as expected.

Environment provided config variables now appear
when queried via `occ config:system:get KEY`

envCache is now free of non-NC stuff.

Signed-off-by: Josh Richards <josh.t.richards@gmail.com>
Signed-off-by: Josh Richards <josh.t.richards@gmail.com>
Signed-off-by: Josh Richards <josh.t.richards@gmail.com>
This was referenced Jul 30, 2024
This was referenced Aug 5, 2024
@skjnldsv skjnldsv mentioned this pull request Aug 13, 2024
@skjnldsv skjnldsv removed this from the Nextcloud 30 milestone Aug 14, 2024
@skjnldsv skjnldsv added this to the Nextcloud 31 milestone Aug 14, 2024
@joshtrichards joshtrichards removed the ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring) label Aug 19, 2024
Signed-off-by: Robin Appelman <robin@icewind.nl>
@icewind1991 icewind1991 merged commit d9c5512 into master Sep 16, 2024
175 checks passed
@icewind1991 icewind1991 deleted the fix-nc-env-inclusion branch September 16, 2024 14:55
@icewind1991
Copy link
Member

/backport to stable30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Overridden config.php variables (via NC_* are not reflected in occ config:system:get command
4 participants