nextcloud / nextcloud/server

[Bug]: `$this->session->get('user_id')` returns `null` since PR 62241 (in dev environment)

Open
#63,137 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage 35-feedback bug team: Files team: IDP
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

⚠️ This issue respects the following points: ⚠️
Bug description

I'm using https://github.com/nextcloud/nextcloud-docker-dev for local development of a Nextcloud app. Using the up to date nextcloud/server master branch within the dev repo, a call to $this->session->get('user_id') returns null. I couldn't find the exact change that causes this but I narrowed it down to the PR https://github.com/nextcloud/server/pull/62241. Before that PR was merged into master, $this->session->get('user_id') would return the session's user ID.

Steps to reproduce
  1. Setup https://github.com/nextcloud/nextcloud-docker-dev
  2. Configure a debugger
  3. Set a breakpoint in a file using $this->session->get('user_id') (I used workspace/server/lib/private/DateTimeZone.php line 30 for this)
  4. Start the dev environment
  5. Open the local Nextcloud instance with your browser
  6. Login as admin
  7. Enable debugging in the docker container
  8. Start debugging
  9. Refresh the browser page
  10. Observe $this->session->get('user_id') returning null
Expected behavior

$this->session->get('user_id') should return the session's user ID, like it did before PR https://github.com/nextcloud/server/pull/62241

Nextcloud Server version

35 (master)

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.3

Web server

Apache (supported)

Database engine version

MySQL

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

Fresh Nextcloud Server install

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?
  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other
Configuration report

List of activated Apps

Nextcloud Signing status

Nextcloud Logs

Additional info

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing PR 62241 and the session access observed at workspace/server/lib/private/DateTimeZone.php line 30. Reproduce the issue with nextcloud-docker-dev, a debugger, PHP 8.3, and a logged-in admin, then trace why the session user ID is null. Done means $this->session->get('user_id') returns the logged-in user's ID again in the development environment.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
authentication, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.