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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

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

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 <[email protected]>
@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
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 backport-request bug ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring)
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
2 participants