[Bug]: ShareApiController currentuser property type issue
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
In
https://github.com/nextcloud/server/blob/master/apps/files_sharing/lib/Controller/ShareAPIController.php#L63C2-L63C30
the currentUser property is typed as string, but in constructor the parameter is signed as ?string $userId = null , so in some circumstances there is this error:
Exception":"TypeError, Cannot assign null to property OCA\\Files_Sharing\\Controller\\ShareAPIController::$currentUser of type string
Steps to reproduce
- It happens when share api is used via webapppassword in nc 29
Expected behavior
Allow userId to be null when using createShare method setting the property type the same as the parameter type.
Installation method
None
Nextcloud Server version
29
Operating system
None
PHP engine version
None
Web server
None
Database engine version
None
Is this bug present after an update or on a fresh install?
None
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
No response
List of activated Apps
No response
Nextcloud Signing status
No response
Nextcloud Logs
{
"reqId": "2M3DAMpzQRlKeiad9X2L",
"level": 3,
"time": "2024-06-24T18:22:46+00:00",
"remoteAddr": "188.77.44.131",
"user": "--",
"app": "index",
"method": "OPTIONS",
"url": "/index.php/apps/webapppassword/api/v1/shares",
"message": "Cannot assign null to property OCA\\Files_Sharing\\Controller\\ShareAPIController::$currentUser of type string",
"userAgent": "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0",
"version": "29.0.2.2",
"exception": {
"Exception": "TypeError",
"Message": "Cannot assign null to property OCA\\Files_Sharing\\Controller\\ShareAPIController::$currentUser of type string",
"Code": 0,
"Trace": [
{
"function": "__construct",
"class": "OCA\\Files_Sharing\\Controller\\ShareAPIController",
"type": "->"
},
{
"file": "web/lib/private/AppFramework/Utility/SimpleContainer.php",
"line": 83,
"function": "newInstanceArgs",
"class": "ReflectionClass",
"type": "->"
},
{
"file": "web/lib/private/AppFramework/Utility/SimpleContainer.php",
"line": 128,
"function": "buildClass",
"class": "OC\\AppFramework\\Utility\\SimpleContainer",
"type": "->"
},
{
"file": "web/lib/private/AppFramework/Utility/SimpleContainer.php",
"line": 146,
"function": "resolve",
"class": "OC\\AppFramework\\Utility\\SimpleContainer",
"type": "->"
},
{
"file": "web/lib/private/AppFramework/DependencyInjection/DIContainer.php",
"line": 470,
"function": "query",
"class": "OC\\AppFramework\\Utility\\SimpleContainer",
"type": "->"
},
{
"file": "web/lib/private/AppFramework/DependencyInjection/DIContainer.php",
"line": 442,
"function": "queryNoFallback",
"class": "OC\\AppFramework\\DependencyInjection\\DIContainer",
"type": "->"
},
{
"file": "web/lib/private/AppFramework/App.php",
"line": 163,
"function": "query",
"class": "OC\\AppFramework\\DependencyInjection\\DIContainer",
"type": "->"
},
{
"file": "web/lib/private/Route/Router.php",
"line": 338,
"function": "main",
"class": "OC\\AppFramework\\App",
"type": "::"
},
{
"file": "web/lib/base.php",
"line": 1050,
"function": "match",
"class": "OC\\Route\\Router",
"type": "->"
},
{
"file": "web/index.php",
"line": 49,
"function": "handleRequest",
"class": "OC",
"type": "::"
}
],
"File": "web/apps/files_sharing/lib/Controller/ShareAPIController.php",
"Line": 124,
"message": "Cannot assign null to property OCA\\Files_Sharing\\Controller\\ShareAPIController::$currentUser of type string",
"exception": {},
"CustomMessage": "Cannot assign null to property OCA\\Files_Sharing\\Controller\\ShareAPIController::$currentUser of type string"
}
}
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
Open apps/files_sharing/lib/Controller/ShareAPIController.php and inspect the currentUser property near line 63 and the constructor near line 124. Reproduce or review the webapppassword share API path that supplies a null userId. Done means the controller no longer raises the reported TypeError when createShare is used with that path, with relevant tests or checks passing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100