fix: detect inadvertent overlapping config files that break things#49956
Open
joshtrichards wants to merge 1 commit intomasterfrom
Open
fix: detect inadvertent overlapping config files that break things#49956joshtrichards wants to merge 1 commit intomasterfrom
joshtrichards wants to merge 1 commit intomasterfrom
Conversation
Fixes #32648 Detects when there are multiple config files and any of them other than the default `config.php` contain a `version` string: the telltale sign of an inadvertent `*.config.php` (such as a backup) existing in `config/` and creating a conflict (which breaks upgrades). Also refactors error message handling. Signed-off-by: Josh <josh.t.richards@gmail.com>
Member
|
Also see #49926. |
solracsf
reviewed
Dec 22, 2024
| // Try to acquire a file lock | ||
| if (!flock($filePointer, LOCK_SH)) { | ||
| throw new \Exception(sprintf('Could not acquire a shared lock on the config file %s', $file)); | ||
| http_response_code(500); |
Member
There was a problem hiding this comment.
Use Http framework:
server/lib/public/AppFramework/Http.php
Line 253 in ce29068
solracsf
reviewed
Dec 22, 2024
| if (isset($CONFIG) && is_array($CONFIG)) { | ||
| // try to detect unintentionally overlapping config files (which will break things like upgrades) | ||
| if (isset($CONFIG['version']) && $file !== $this->configFilePath) { | ||
| http_response_code(500); |
Merged
This was referenced Aug 22, 2025
Merged
Merged
Merged
Merged
This was referenced Sep 4, 2025
Merged
Merged
Merged
This was referenced Sep 25, 2025
Merged
Merged
Merged
This was referenced Jan 29, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
*.config.phpfiles to catch weird config problems #46665Summary
Addresses avoidable support matters (on the forum/etc) and invalid bug reports about updating/upgrading problems when people back up their
config.phpas something likeold.config.php. This can create numerous problems (i.e. "Why are my config changes never taking effect?" and "Why does my Nextcloud keep saying it needs an upgrade after upgrading?").This PR detects when there are multiple config files and any of them (other than the default
config.php) contain aversionstring. This is a telltale sign of an inadvertent*.config.php(such as a backup) existing inconfig/and creating a conflict.Since this is a Nextcloud Server managed parameter + the built-in updater doesn't even support multiple configuration files there is virtually zero chance this is a valid situation. So we consider it fatal.
PR also lightly enhances and refactors error message handling same area of code a bit:
Fatal error: Uncaught Error: Typed static property OC::$server must not be accessed before initialization in /[...]alongside the actual error)basenamein all, not just most cases (to minimize exposure of unnecessary path details to unauthenticated users when seen via the web)TODO
Checklist