fix(appconfig,userconfig): restore pre-migration fallback for ownCloud migration#59677
Conversation
50e03d9 to
a4d8e29
Compare
|
This works ! Please merge it soon, if possible :) |
|
/backport to stable34 |
|
/backport to stable33 |
|
/backport to stable32 |
4aca08b to
343ceb5
Compare
…d migration AppConfig and UserConfig unconditionally queried NC-only columns (type, lazy, flags, indexed) that don't exist in ownCloud's database schema, breaking ownCloud → Nextcloud upgrades entirely before the schema migration steps could run. Restore the fallback pattern in both classes: on first loadConfig() call, if a DBException with REASON_INVALID_FIELD_NAME is thrown, set $migrationCompleted = false and retry selecting only the columns present in ownCloud's schema. INSERT and UPDATE statements also omit NC-only columns when $migrationCompleted is false. The catch block also guards against infinite recursion: if $migrationCompleted is already false when the exception fires, the exception is re-thrown instead of triggering another recursive call. Fixes: #57340 Signed-off-by: Anna Larch <anna@nextcloud.com> AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com>
343ceb5 to
b2c9273
Compare
|
Awesome @miaulalala, I highly appreciate the efforts to restore a seamless ownCloud 10 => Nextcloud migration! ❤️ The respective documentation page needs to be updated, to reflect a supported upgrade path to latest Nextcloud, right? https://docs.nextcloud.com/server/latest/admin_manual/maintenance/migrating_owncloud.html I can open a PR, if confirmed. EDIT: Ah, I did not think about the conflicting PHP version requirements, which would at least require some explanation in the docs. The preferred migration path IMO would be still to latest Nextcloud directly. But one needs to upgrade PHP first. |
If you want to give the documentation a shot, that would be lovely! Ping me on the PR and if you're unsure about anything, I can help you or do the rest, whatever you prefer. I appreciate it 😃 |
|
I opened nextcloud/documentation#15048, and indeed there are some open questions. It is currently half way: migration to latest Nextcloud, but still keeping the table and conditional migration steps, in case latest Nextcloud removes support for migration from older ownCloud versions at some point. But IMO, in that case, upgrading from that ownCloud version should not be supported (and hence not documented) at all. No one will and can guarantee it works, and admins should always be able to upgrade to a supported ownCloud version first. I discussed this in the PR, anyone please let me know what you think, as the page could be simplified/compacted in case. |
nextcloud/server#59677 fixes direct migration from ownCloud to latest Nextcloud. It does not change something about the fact that latest ownCloud 10 does not support any PHP version supported by Nextcloud. But while keeping PHP 7.4 during the migration to Nextcloud 25 makes it easier to revert to ownCloud in case of an issue, that path requires manually patching `version.php`, a lot of major version upgrades, and intermediate PHP upgrade steps. Overall the efforts are a lot higher than migration directly to latest Nextcloud, and upgrade PHP only once prior to that. Another reason to prefer direct migration to latest Nextcloud is, that Nextcloud 25 migrations are not maintained anymore. There is hence a chance that some recent ownCloud 10 version introduces a change that causes a major or subtil issue during the migration, that is fixed only in Nextcloud versions which are not EOL. The migration steps have been adjusted to reflect the direct migration path to the upcoming Nextcloud 34.0.0. The table itself, to in case list different migration paths for different ownCloud versions, has been left in place, including the optional/conditional migration steps to further upgrade Nextcloud and in case PHP afterwards. However, to reduce maintenance efforts and simplify/clarify things, I'd vote for removing support for migration to any older Nextcloud versions entirely, and remove the target version and post-migration upgrade steps from the docs. Once latest Nextcloud removes support for migrations from ownCloud 10.13.x, it is probably better to simply remove this migration path from the docs, and require admins to upgrade ownCloud first. IMO, keeping support for (and documenting) migrations to Nextcloud versions, which themselves are not supported, and hence do not get possibly needed fixes for migration scripts and `version.php`, does not make sense. Let me know if you agree to the last point, then I'll adjust the commit accordingly. Signed-off-by: MichaIng <micha@dietpi.com> Signed-off-by: MichaIng <micha@dietpi.com>
Summary
ownCloud → Nextcloud migration broke in NC31+ because
AppConfigandUserConfigunconditionally query columns (type,lazy,flags,indexed) that were added by Nextcloud and don't exist in ownCloud's database schema. These columns are only created by migration steps that can't run until the app config system is already functional — a chicken-and-egg problem that caused the entire upgrade to fail with an invalid field name error.Root cause: A pre-existing try/catch fallback in
AppConfig::loadConfig()was removed in a572a5c without a replacement.UserConfignever had an equivalent guard.Fix: Restore the fallback pattern in both classes:
loadConfig()call, if aDBExceptionwithREASON_INVALID_FIELD_NAMEis thrown, set$migrationCompleted = falseand retry selecting only the columns present in ownCloud's schema (appid,configkey,configvalue/userid)$migrationCompleted = false, INSERT and UPDATE statements also omit the NC-only columns (type,lazy,flags,indexed) so writes don't fail eitherThis allows the migration infrastructure to boot successfully so the schema migration steps can run and add the missing columns.
Fixes: #57340
Test plan
AppConfigMigrationFallbackTest— unit tests forAppConfig:REASON_INVALID_FIELD_NAMEUserConfigMigrationFallbackTest— same three cases forUserConfigChecklist
3. to review, feature component)stable32)AI (if applicable)
AI-Assisted-By: Claude Sonnet 4.6 noreply@anthropic.com