Skip to content

Conversation

@Pytal
Copy link
Member

@Pytal Pytal commented Oct 7, 2022

Fix #34458 #34216

Background settings previously were set in the oc_preferences table with the appid "dashboard", after #33733 the settings were queried for with the appid "theming"

This migration aims to fix the background loss on upgrade by updating the appid to "theming"

@Pytal Pytal added this to the Nextcloud 26 milestone Oct 7, 2022
@Pytal Pytal requested review from blizzz and nickvergessen October 7, 2022 02:31
@Pytal Pytal self-assigned this Oct 7, 2022
@Pytal
Copy link
Member Author

Pytal commented Oct 7, 2022

/backport to stable25

@Pytal
Copy link
Member Author

Pytal commented Oct 7, 2022

The migration looks right but doesn't seem to work, any ideas why @blizzz?

@nickvergessen nickvergessen requested review from a team, PVince81 and juliusknorr and removed request for a team October 7, 2022 10:37
@PVince81 PVince81 requested a review from CarlSchwan October 12, 2022 16:16
@Pytal Pytal force-pushed the fix/migrate-background branch from b4c38a7 to 1954de0 Compare October 13, 2022 00:19
@Pytal
Copy link
Member Author

Pytal commented Oct 13, 2022

Probably just my local instance not working but updated and ready for review

Copy link
Member

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 as discussed

@PVince81
Copy link
Member

@blizzz we need this for 25.0.0RC4

Copy link
Contributor

@come-nc come-nc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would feel better if it checked theming/background is not set before overwriting it.

@PVince81
Copy link
Member

I would feel better if it checked theming/background is not set before overwriting it.

this is what we wanted to avoid as it would require iterating over all users and slow down the migration/update

in normal cases the migration would not rerun

@PVince81
Copy link
Member

and because of those duplicates as in #34461 (comment) we cannot simply run the update like in the first version of this PR:

MariaDB [nextcloud]> update oc_preferences set appid='dashboard' where configkey in ('background', 'backgroundVersion');
ERROR 1062 (23000): Duplicate entry 'bob-dashboard-background' for key 'PRIMARY'

so the proposal was to delete the backgrounds that were set post RC, here by Bob, by deleting the matching "theming" keys.

so that in the end only users (early adopters) will have to manually re-set the background

@blizzz blizzz linked an issue Oct 13, 2022 that may be closed by this pull request
9 tasks
@blizzz
Copy link
Member

blizzz commented Oct 13, 2022

updated the description and linked issue.

@PVince81
Copy link
Member

@blizzz please check oc_preferences for my user on c.nc.com, my background is still black as I haven't re-selected one.
then we can see the DB state

@blizzz
Copy link
Member

blizzz commented Oct 13, 2022

> select appid, configkey, configvalue from oc_preferences where configkey in ('background', 'backgroundVersion') and userid = '*******';
+---------+-------------------+-------------+
| appid   | configkey         | configvalue |
+---------+-------------------+-------------+
| theming | background        | custom      |
| theming | backgroundVersion | 5           |
+---------+-------------------+-------------+

@blizzz
Copy link
Member

blizzz commented Oct 13, 2022

@blizzz please check oc_preferences for my user on c.nc.com, my background is still black as I haven't re-selected one. then we can see the DB state

I had selected on in rc2 which vanished in rc3 and was all black for me. Maybe pre-condition is coming from 24.

@PVince81
Copy link
Member

I checked user "Alice" on my test system which would represent that test case and here the background is reset to default instead of black.

Maybe c.nc.com is missing that cloudy default pic ?

@blizzz
Copy link
Member

blizzz commented Oct 13, 2022

I checked user "Alice" on my test system which would represent that test case and here the background is reset to default instead of black.

Maybe c.nc.com is missing that cloudy default pic ?

Nope.

@PVince81
Copy link
Member

@blizzz or maybe one needs to upgrade through RC1, RC2, etc to reach that state.

also would need to check in which key the path to the custom bkg image is set, maybe that one can be broken as well ?

@blizzz
Copy link
Member

blizzz commented Oct 13, 2022

@blizzz or maybe one needs to upgrade through RC1, RC2, etc to reach that state.

also would need to check in which key the path to the custom bkg image is set, maybe that one can be broken as well ?

Maybe RC 1 then at most. I went now from 24.0.6 (dark mode, non-default stock background) via rc2 (became default background, changed to custom picked from files) and the to RC3. It stayed. So if there was something with rc (or the beta), it does not really matter now. Will close #34458 and do another check with this PR to confirm #34216 is fixed.

@blizzz
Copy link
Member

blizzz commented Oct 13, 2022

Now I took 24.0.6, uploaded a file and set this as background. Then upgrade to RC3 + this patch. Now I have a black background, so, does not really work.

Database entries were set correctly, but apparently this is not enough.

@blizzz
Copy link
Member

blizzz commented Oct 13, 2022

Files need to be moved

data/$APPDATA_DIR/dashboard/$USERID/background.jpg → data/$APPDATA_DIR/theming/$USERID/background.jpg

@blizzz
Copy link
Member

blizzz commented Oct 13, 2022

We can do this on demand in the BackgroundService and copy the file contents around. But then we have to carry the cargo a bit.

Or we just have the fallback in the BackgroundService and add an expensive background or repair job, that would move them once in the maintenance times. Then the code can be removed for 26 (some case has to be given on chained upgrades to ensure those are run, but that's ops).

@PVince81
Copy link
Member

maybe the BackgroundService could migrate it at login time ?

@PVince81
Copy link
Member

adding the latest idea from internal discussion with @blizzz:

  • add a fallback in BackgroundService that checks both locations in oc_preferences and also on disk
  • have a time-insensitive (nightly) background job that migrates the oc_preferences keys and also the image file

there's some local WIP work towards this idea that will be pushed later

@PVince81
Copy link
Member

update:

the fallback + background job for migration is only for the background file, not the config.
we still migrate the config in this PR

- fallback to background image from old location
- migrate background images to new location as insensitive job

Signed-off-by: Arthur Schiwon <[email protected]>
@blizzz blizzz added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Oct 13, 2022
@PVince81
Copy link
Member

I've redone this test:

  1. Start with v24.0.6 with three users: alice, bob, charles
  2. Login as alice and set a dashboard wallpaper from a local file
  3. Login as bob and set a dashboard wallpaper from a local file
  4. Upgrade to v25.0.0 RC2
  5. As alice, set a theming wallpaper
  6. As charles, set a theming wallpaper
  7. Switch to this branch
  8. Upgrade
  9. Check all user's wallpaper
MariaDB [nextcloud]> select * from oc_preferences where appid in ('theming', 'dashboard');
+---------+-----------+-------------------+-------------+
| userid  | appid     | configkey         | configvalue |
+---------+-----------+-------------------+-------------+
| alice   | dashboard | firstRun          | 0           |
| alice   | theming   | background        | custom      |
| alice   | theming   | backgroundVersion | 2           |
| bob     | dashboard | firstRun          | 0           |
| bob     | theming   | background        | custom      |
| bob     | theming   | backgroundVersion | 1           |
| charles | dashboard | firstRun          | 0           |
+---------+-----------+-------------------+-------------+

in appdata:

dashboard
├── alice
│   └── background.jpg
└── bob
    └── background.jpg
theming
├── 1
│   ├── favIcon-core
│   ├── favIcon-dashboard
│   └── icon-core-filetypes_text.svg
├── alice
│   └── background.jpg
└── charles
    └── background.jpg

3 directories, 5 files
  • Alice: wallpaper is visible ✅
  • Bob: wallpaper is visible through fallback: ✅
  • Charles: wallpaper is gone, this is by design as discussed for users who created in RC2 ✅
  1. Run background jobs
  2. Check tree again
dashboard
├── alice
└── bob
theming
├── 1
│   ├── favIcon-core
│   ├── favIcon-dashboard
│   └── icon-core-filetypes_text.svg
├── alice
│   └── background.jpg
├── bob
│   └── background.jpg
└── charles
    └── background.jpg

4 directories, 6 files
  • Alice: wallpaper is visible ✅
  • Bob: wallpaper is visible: ✅

Note: sadly I still need to shift+refresh to get the wallpapers to refresh, separate issue

tldr; works as expected 👍

@PVince81 PVince81 enabled auto-merge October 13, 2022 17:01
@PVince81
Copy link
Member

  • raise a ticket to make the background job more scalable with a lot of users as we don't want to fetch a lot of users every time the job runs @blizzz

$this->jobList = $jobList;
}

protected function run($argument): void {

Check notice

Code scanning / Psalm

MissingParamType

Parameter $argument has no provided type
return 'Initialize migration of background images from dashboard to theming app';
}

public function run(IOutput $output) {

Check notice

Code scanning / Psalm

MissingReturnType

Method OCA\Theming\Migration\InitBackgroundImagesMigration::run does not have a return type, expecting void
@PVince81 PVince81 merged commit c0c0387 into master Oct 13, 2022
@PVince81 PVince81 deleted the fix/migrate-background branch October 13, 2022 18:10
@backportbot-nextcloud
Copy link

backportbot-nextcloud bot commented Oct 13, 2022

The backport to stable25 failed. Please do this backport manually.

#34587

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4. to release Ready to be released and/or waiting for tests to finish bug feature: dashboard feature: theming

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Background chosen in NC 24 is not migrated to NC 25 upon upgrade

8 participants