[Bug]: `$this->session->get('user_id')` returns `null` since PR 62241 (in dev environment)
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 36.9k
- Forks
- 5.2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 713
Description
⚠️ 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 OR Nextcloud Community Forum (I've searched it).
- Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
- I agree to follow Nextcloud's Code of Conduct.
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
- Setup https://github.com/nextcloud/nextcloud-docker-dev
- Configure a debugger
- Set a breakpoint in a file using
$this->session->get('user_id')(I usedworkspace/server/lib/private/DateTimeZone.phpline 30 for this) - Start the dev environment
- Open the local Nextcloud instance with your browser
- Login as admin
- Enable debugging in the docker container
- Start debugging
- Refresh the browser page
- Observe
$this->session->get('user_id')returningnull
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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