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

[Bug] [25.0.0RC4] Custom background doesn't stay (404) #34596

Closed
5 of 9 tasks
PVince81 opened this issue Oct 14, 2022 · 16 comments · Fixed by #34599
Closed
5 of 9 tasks

[Bug] [25.0.0RC4] Custom background doesn't stay (404) #34596

PVince81 opened this issue Oct 14, 2022 · 16 comments · Fixed by #34599
Assignees
Milestone

Comments

@PVince81
Copy link
Member

⚠️ This issue respects the following points: ⚠️

  • This is a bug, not a question or a configuration/webserver/proxy issue.
  • This issue is not already reported on Github (I've searched it).
  • Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
  • Nextcloud Server is running on 64bit capable CPU, PHP and OS.
  • I agree to follow Nextcloud's Code of Conduct.

Bug description

Getting a 404 on a custom background: GET https://.../index.php/apps/theming/background

MariaDB [nextcloud]> select * from oc_preferences where userid='alice' and appid in ('dashboard', 'theming');
+--------+-----------+-------------------+-------------+
| userid | appid     | configkey         | configvalue |
+--------+-----------+-------------------+-------------+
| alice  | dashboard | firstRun          | 0           |
| alice  | theming   | background        | custom      |
| alice  | theming   | backgroundVersion | 1           |
+--------+-----------+-------------------+-------------+
3 rows in set (0.001 sec)

file "background.jpg" is missing on disk in "data/appdata_*/theming/alice"

Steps to reproduce

  1. Create three users Alice, Bob and Charles
  2. Login as Alice
  3. Upload an image
  4. Set that image as custom background
  5. Go to files app and shift+refresh to see it

Expected behavior

Background appears and exists on disk

Installation method

No response

Operating system

No response

PHP engine version

No response

Web server

No response

Database engine version

No response

Is this bug present after an update or on a fresh install?

No response

Are you using the Nextcloud Server Encryption module?

No response

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

No response

List of activated Apps

N/A

Nextcloud Signing status

No response

Nextcloud Logs

{
  "reqId": "yGU73Yn4alZXEjEKqNf7",
  "level": 3,
  "time": "2022-10-14T07:50:24+00:00",
  "remoteAddr": "127.0.0.1",
  "user": "--",
  "app": "index",
  "method": "GET",
  "url": "/index.php/apps/theming/background?v=2",
  "message": "Call to a member function getUID() on null",
  "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36",
  "version": "25.0.0.16",
  "exception": {
    "Exception": "Error",
    "Message": "Call to a member function getUID() on null",
    "Code": 0,
    "Trace": [
      {
        "function": "__construct",
        "class": "OCA\\Theming\\Controller\\UserThemeController",
        "type": "->",
        "args": [
          "theming",
          {
            "__class__": "OC\\AppFramework\\Http\\Request"
          },
          {
            "__class__": "OC\\AllConfig"
          },
          {
            "__class__": "OC\\User\\Session"
          },
          {
            "__class__": "OCA\\Theming\\Service\\ThemesService"
          },
          {
            "__class__": "OCA\\Theming\\ThemingDefaults"
          },
          {
            "__class__": "OCA\\Theming\\Service\\BackgroundService"
          }
        ]
      },
      {
        "file": "/srv/www/htdocs/server/lib/private/AppFramework/Utility/SimpleContainer.php",
        "line": 108,
        "function": "newInstanceArgs",
        "class": "ReflectionClass",
        "type": "->",
        "args": [
          [
            "theming",
            {
              "__class__": "OC\\AppFramework\\Http\\Request"
            },
            {
              "__class__": "OC\\AllConfig"
            },
            {
              "__class__": "OC\\User\\Session"
            },
            {
              "__class__": "OCA\\Theming\\Service\\ThemesService"
            },
            {
              "__class__": "OCA\\Theming\\ThemingDefaults"
            },
            {
              "__class__": "OCA\\Theming\\Service\\BackgroundService"
            }
          ]
        ]
      },
      {
        "file": "/srv/www/htdocs/server/lib/private/AppFramework/Utility/SimpleContainer.php",
        "line": 116,
        "function": "buildClass",
        "class": "OC\\AppFramework\\Utility\\SimpleContainer",
        "type": "->",
        "args": [
          {
            "__class__": "ReflectionClass",
            "name": "OCA\\Theming\\Controller\\UserThemeController"
          }
        ]
      },
      {
        "file": "/srv/www/htdocs/server/lib/private/AppFramework/Utility/SimpleContainer.php",
        "line": 133,
        "function": "resolve",
        "class": "OC\\AppFramework\\Utility\\SimpleContainer",
        "type": "->",
        "args": [
          "OCA\\Theming\\Controller\\UserThemeController"
        ]
      },
      {
        "file": "/srv/www/htdocs/server/lib/private/AppFramework/DependencyInjection/DIContainer.php",
        "line": 465,
        "function": "query",
        "class": "OC\\AppFramework\\Utility\\SimpleContainer",
        "type": "->",
        "args": [
          "OCA\\Theming\\Controller\\UserThemeController"
        ]
      },
      {
        "file": "/srv/www/htdocs/server/lib/private/AppFramework/DependencyInjection/DIContainer.php",
        "line": 437,
        "function": "queryNoFallback",
        "class": "OC\\AppFramework\\DependencyInjection\\DIContainer",
        "type": "->",
        "args": [
          "OCA\\Theming\\Controller\\UserThemeController"
        ]
      },
      {
        "file": "/srv/www/htdocs/server/lib/private/AppFramework/App.php",
        "line": 159,
        "function": "query",
        "class": "OC\\AppFramework\\DependencyInjection\\DIContainer",
        "type": "->",
        "args": [
          "OCA\\Theming\\Controller\\UserThemeController"
        ]
      },
      {
        "file": "/srv/www/htdocs/server/lib/private/Route/Router.php",
        "line": 298,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::",
        "args": [
          "OCA\\Theming\\Controller\\UserThemeController",
          "getBackground",
          {
            "__class__": "OC\\AppFramework\\DependencyInjection\\DIContainer"
          },
          [
            "theming.userTheme.getBackground"
          ]
        ]
      },
      {
        "file": "/srv/www/htdocs/server/lib/base.php",
        "line": 1047,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->",
        "args": [
          "/apps/theming/background"
        ]
      },
      {
        "file": "/srv/www/htdocs/server/index.php",
        "line": 36,
        "function": "handleRequest",
        "class": "OC",
        "type": "::",
        "args": []
      }
    ],
    "File": "/srv/www/htdocs/server/apps/theming/lib/Controller/UserThemeController.php",
    "Line": 76,
    "CustomMessage": "--"
  }
}

Additional info

No response

@PVince81 PVince81 added bug 0. Needs triage Pending check for reproducibility or if it fits our roadmap labels Oct 14, 2022
@PVince81 PVince81 self-assigned this Oct 14, 2022
@PVince81 PVince81 added 1. to develop Accepted and waiting to be taken care of regression and removed 0. Needs triage Pending check for reproducibility or if it fits our roadmap labels Oct 14, 2022
@PVince81 PVince81 added this to the Nextcloud 25 milestone Oct 14, 2022
@PVince81
Copy link
Member Author

how can getUser() be null ? is there an issue with the lifecycle ?

@PVince81
Copy link
Member Author

I've done further tests and directly after setting the background, I see background.jpg appearing in appdata under the "theming" app

but as soon as I shift+refresh, that file disappears

maybe the migration code / cron (ajax cron on local env) is wrongly deleting the file. Ref: #34587

@PVince81
Copy link
Member Author

@blizzz FYI

@PVince81
Copy link
Member Author

it's not the migration job, when commented out a shift+refresh (at most 2x) will delete "background.jpg".

not sure if it's the null user or something else at play

@PVince81 PVince81 added the high label Oct 14, 2022
@PVince81
Copy link
Member Author

also note, I have custom theme colors set, in case it matters:

MariaDB [nextcloud]> select * from oc_appconfig where appid='theming';
+---------+-------------------+----------------------------+
| appid   | configkey         | configvalue                |
+---------+-------------------+----------------------------+
| theming | cachebuster       | 9                          |
| theming | color             | #C96C42                    |
| theming | enabled           | yes                        |
| theming | installed_version | 2.0.0                      |
| theming | slogan            | a safe dev env for my data |
| theming | types             | logging                    |
+---------+-------------------+----------------------------+

@PVince81
Copy link
Member Author

it's not the "/background" endpoint, I tried refreshing it in a separate tab and background.jpg does not get deleted

maybe it's the settings page that resets it upon reload?

@PVince81
Copy link
Member Author

ok, we found the issue, it has multiple layers:

  1. Here we are clearing the theme's cache:

    $this->themingDefaults->increaseCacheBuster();
    which in itself shouldn't be a bad thing, and Separate backend admin and user theming #34472 is for separating the cache buster part. However, see 2)

  2. When clearing the admin theme, it will delete everything inside the "appdata_*/theming folder" including the user data.

  3. The cache buster value and the user names are colliding inside the "theming" folder => here we need to separate the global and user theme data into separate folders "theming/global/$cacheBusterValue" and "theming/global/$userId"

@PVince81
Copy link
Member Author

Fix is here: #34599

@blizzz blizzz mentioned this issue Oct 14, 2022
1 task
@skjnldsv skjnldsv added 3. to review Waiting for reviews and removed 1. to develop Accepted and waiting to be taken care of labels Oct 14, 2022
@mueslo
Copy link

mueslo commented Oct 25, 2022

I do not believe this is fixed. I just upgraded from NC 24.0.5 to 25.0.0 (stable) and the background image disappeared.

The previously-set background image caused 404s (I did not immediately notice it after the upgrade due to client-side caching, I assume). But today, it resulted in 404s for the background image, and in the admin panel the background image was also empty.

@Skamandrios
Copy link

I just upgraded from 24.0.7 to 25.0.1 and the custom theming was not applied. This affects the background, as well as the custom logos.

@ffried
Copy link

ffried commented Dec 12, 2022

Same here. Upgraded two NextCloud instances to 25.0.2 and both of them have no background images now. One of them had a custom logo as well which is also gone now.

Logs on both instances show this:

[cron] Error: TypeError: Cannot access offset of type string on string at <<closure>>

0. /var/www/html/lib/public/BackgroundJob/Job.php line 78
   OCA\Theming\Jobs\MigrateBackgroundImages->run("execute")
1. /var/www/html/lib/public/BackgroundJob/QueuedJob.php line 58
   OCP\BackgroundJob\Job->start(OC\BackgroundJob\JobList {})
2. /var/www/html/lib/public/BackgroundJob/QueuedJob.php line 48
   OCP\BackgroundJob\QueuedJob->start(OC\BackgroundJob\JobList {})
3. /var/www/html/cron.php line 152
   OCP\BackgroundJob\QueuedJob->execute(OC\BackgroundJob\JobList {}, OC\Log {})

at 2022-12-12T07:10:03+00:00

Or in raw:

{"reqId":"ymvZGE0VyBi6LkhprSWT","level":3,"time":"2022-12-12T07:10:03+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","message":"Cannot access offset of type string on string","userAgent":"--","version":"25.0.2.3","exception":{"Exception":"TypeError","Message":"Cannot access offset of type string on string","Code":0,"Trace":[{"file":"/var/www/html/lib/public/BackgroundJob/Job.php","line":78,"function":"run","class":"OCA\\Theming\\Jobs\\MigrateBackgroundImages","type":"->","args":["execute"]},{"file":"/var/www/html/lib/public/BackgroundJob/QueuedJob.php","line":58,"function":"start","class":"OCP\\BackgroundJob\\Job","type":"->","args":[{"__class__":"OC\\BackgroundJob\\JobList"}]},{"file":"/var/www/html/lib/public/BackgroundJob/QueuedJob.php","line":48,"function":"start","class":"OCP\\BackgroundJob\\QueuedJob","type":"->","args":[{"__class__":"OC\\BackgroundJob\\JobList"}]},{"file":"/var/www/html/cron.php","line":152,"function":"execute","class":"OCP\\BackgroundJob\\QueuedJob","type":"->","args":[{"__class__":"OC\\BackgroundJob\\JobList"},{"__class__":"OC\\Log"}]}],"File":"/var/www/html/apps/theming/lib/Jobs/MigrateBackgroundImages.php","Line":74,"CustomMessage":"--"},"id":"6396d564ab0c4"}

@ffried
Copy link

ffried commented Dec 12, 2022

And I think the issue is this line:
https://github.com/nextcloud/server/pull/34677/files#diff-359221f5daddbe538fe970eddb46e5f77d6993679fb9626eacf8e3cdf81c230fR105

This should probably be

$this->jobList->add(self::class, ['stage' => self::STAGE_EXECUTE]);

@jdkruzr
Copy link

jdkruzr commented Dec 24, 2022

hi, this error shows up on my new 25.0.2 install, and I haven't even set a custom background. the error shows up when I try to manually run cron.php (which I have to do in order to troubleshoot cron, because the cron job just isn't working for some reason)

@Draluy
Copy link

Draluy commented Dec 27, 2022

I'm exactly on the same page as @jdkruzr here. I launched cron.php manually once to test, and subsequent runs show this error.

docker exec --user www-data nextcloud_app_1  php cron.php
TypeError: Cannot access offset of type string on string in /var/www/html/apps/theming/lib/Jobs/MigrateBackgroundImages.php:74
Stack trace:
#0 /var/www/html/lib/public/BackgroundJob/Job.php(78): OCA\Theming\Jobs\MigrateBackgroundImages->run('execute')
#1 /var/www/html/lib/public/BackgroundJob/QueuedJob.php(58): OCP\BackgroundJob\Job->start(Object(OC\BackgroundJob\JobList))
#2 /var/www/html/lib/public/BackgroundJob/QueuedJob.php(48): OCP\BackgroundJob\QueuedJob->start(Object(OC\BackgroundJob\JobList))
#3 /var/www/html/cron.php(152): OCP\BackgroundJob\QueuedJob->execute(Object(OC\BackgroundJob\JobList), Object(OC\Log))
#4 {main}

@jdkruzr
Copy link

jdkruzr commented Dec 27, 2022

@Draluy I have since gotten it working, although I couldn't tell you exactly how. But, maybe of some note: my installation isn't even Dockerized and we had the same issue.

@kyrofa
Copy link
Member

kyrofa commented Jan 1, 2023

Just saw that error in the snap when upgrading from v24 to v25. Something seems to be broken, but whatever it is only seems to happen on upgrade-- works fine once the upgrade is done. Maybe a left-over queued job from v24 with a different argument than expected in the v25 codebase?

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