-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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]: ShareApiController currentuser property type issue #46081
Comments
How is that supposed to? We need the userId to create the share. |
excuse me if i'm wrong but ¿ why then the constructor allows it to be null? or I am missing something? |
You are not wrong. We usually use Would you mind sending us a pull request with your suggested fix? I guess it's fine to update the type hint. |
Well, let me show the big frame. I found this issue when adapting the controller that extends the ShareApiController in the app webapppassword to allow the use of share api outside of nextcloud. If we are trying to use the current controller in https://github.com/digital-blueprint/webapppassword/blob/main/lib/Controller/ShareAPIController.php It arises: {
"reqId": "lbDsFwFLxAyTN4QFQJzx",
"level": 3,
"time": "2024-06-27T14:23:23+00:00",
"remoteAddr": "x.x.x.x",
"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": 88,
"function": "newInstanceArgs",
"class": "ReflectionClass",
"type": "->"
},
{
"file": "/web/lib/private/AppFramework/Utility/SimpleContainer.php",
"line": 133,
"function": "buildClass",
"class": "OC\\AppFramework\\Utility\\SimpleContainer",
"type": "->"
},
{
"file": "/web/lib/private/AppFramework/Utility/SimpleContainer.php",
"line": 151,
"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"
}
}
If I change the type of currentUser property in web/apps/files_sharing/lib/Controller/ShareAPIController.php to match the __construct signature ( so set to
Keeping currentUser property set to |
This error also pops-out on CI logs. |
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
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?
Configuration report
No response
List of activated Apps
No response
Nextcloud Signing status
No response
Nextcloud Logs
Additional info
No response
The text was updated successfully, but these errors were encountered: