Skip to content

fix(appconfig,userconfig): restore pre-migration fallback for ownCloud migration#59677

Open
miaulalala wants to merge 1 commit into
masterfrom
fix/57340/owncloud-migration-appconfig-userconfig
Open

fix(appconfig,userconfig): restore pre-migration fallback for ownCloud migration#59677
miaulalala wants to merge 1 commit into
masterfrom
fix/57340/owncloud-migration-appconfig-userconfig

Conversation

@miaulalala
Copy link
Copy Markdown
Contributor

@miaulalala miaulalala commented Apr 16, 2026

Summary

ownCloud → Nextcloud migration broke in NC31+ because AppConfig and UserConfig unconditionally 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. UserConfig never had an equivalent guard.

Fix: 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 (appid, configkey, configvalue / userid)
  • When $migrationCompleted = false, INSERT and UPDATE statements also omit the NC-only columns (type, lazy, flags, indexed) so writes don't fail either
  • All other exceptions are re-thrown unchanged

This 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 for AppConfig:
    • fallback triggered on REASON_INVALID_FIELD_NAME
    • non-matching exceptions are re-thrown
    • INSERT omits NC-only columns in fallback mode
  • UserConfigMigrationFallbackTest — same three cases for UserConfig

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

AI-Assisted-By: Claude Sonnet 4.6 noreply@anthropic.com

@miaulalala miaulalala added this to the Nextcloud 34 milestone Apr 16, 2026
@miaulalala miaulalala self-assigned this Apr 16, 2026
@miaulalala miaulalala marked this pull request as ready for review May 19, 2026 11:55
@miaulalala miaulalala requested a review from a team as a code owner May 19, 2026 11:55
@miaulalala miaulalala requested review from Altahrim, ArtificialOwl, CarlSchwan and leftybournes and removed request for a team May 19, 2026 11:55
@miaulalala miaulalala modified the milestones: Nextcloud 34, Nextcloud 35 May 19, 2026
@miaulalala miaulalala force-pushed the fix/57340/owncloud-migration-appconfig-userconfig branch from 50e03d9 to a4d8e29 Compare May 19, 2026 12:03
@susnux susnux added the bug label May 19, 2026
@Robert-Riedl
Copy link
Copy Markdown

This works ! Please merge it soon, if possible :)

@miaulalala miaulalala requested a review from sorbaugh May 26, 2026 15:28
@miaulalala
Copy link
Copy Markdown
Contributor Author

/backport to stable34

@miaulalala
Copy link
Copy Markdown
Contributor Author

/backport to stable33

@miaulalala
Copy link
Copy Markdown
Contributor Author

/backport to stable32

@miaulalala miaulalala requested a review from blizzz May 27, 2026 12:57
Comment thread lib/private/Config/UserConfig.php
Comment thread lib/private/AppConfig.php
@miaulalala miaulalala force-pushed the fix/57340/owncloud-migration-appconfig-userconfig branch 2 times, most recently from 4aca08b to 343ceb5 Compare May 27, 2026 16:10
@miaulalala miaulalala enabled auto-merge May 27, 2026 16:15
…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>
@miaulalala miaulalala force-pushed the fix/57340/owncloud-migration-appconfig-userconfig branch from 343ceb5 to b2c9273 Compare May 28, 2026 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Migration from ownCloud not possible since NC31

5 participants