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

Application crash in /solid/lib/Controller/AppController.php #62

Closed
alaincao opened this issue Dec 30, 2021 · 3 comments · Fixed by #63
Closed

Application crash in /solid/lib/Controller/AppController.php #62

alaincao opened this issue Dec 30, 2021 · 3 comments · Fixed by #63
Assignees
Labels
Type: Bug Something isn't working
Milestone

Comments

@alaincao
Copy link

Hi, I just installed this app only to see what it's all about, but could not do anything with it:
Whenever I access '/apps/solid/', I get the NextCloud's internal server error (HTTP 500).
In the NextCloud's logs, I get 3 error entries:

  • [PHP] Error: Undefined variable $userClients at /var/www/html/custom_apps/solid/lib/Controller/AppController.php#37
    GET /apps/solid/
    from 172.18.0.3 by aa at 2021-12-30T15:55:09+00:00
  • [PHP] Error: foreach() argument must be of type array|object, null given at /var/www/html/custom_apps/solid/lib/Controller/AppController.php#37
    GET /apps/solid/
    from 172.18.0.3 by aa at 2021-12-30T15:55:09+00:00
  • [index] Error: in_array(): Argument # 2 ($haystack) must be of type array, string given in file '/var/www/html/custom_apps/solid/lib/Controller/AppController.php' line 55
    GET /apps/solid/
    from 172.18.0.3 by aa at 2021-12-30T15:55:09+00:00

'not too sure what's happenning here.
NextCloud v23.0.0.10
PHP 8.0.14
Apache 2.4.51 from Docker image nextcloud:23.0.0-apache

@alaincao
Copy link
Author

  1. The first 2 seem to be related to me.
    The line 37 refers to variable $userClients. I searched for it but could not find it anywhere and var_dump() tells me it's indeed null...
    I tried to replace it by $allowedClients (an empty array) right above and it seemed to fix (?)
  2. The call to in_array() at line 55 seem to not like the $origin variable. Here's the result of its "var_dump()": string(24) "notepod.vincenttunru.com".
    I tried replacing the line by if(false) and the screen could load successfully (?). Not too sure where to go from here (ie. don't know enough of PHP since I'm a bit allergic to it ;-) ).

@alaincao
Copy link
Author

Full log entry dump:

{"reqId":"MPLFyLESE9hEFsEbktAC","level":3,"time":"2021-12-30T15:55:09+00:00","remoteAddr":"172.18.0.3","user":"aa","app":"PHP","method":"GET","url":"/apps/solid/","message":"Undefined variable $userClients at /var/www/html/custom_apps/solid/lib/Controller/AppController.php#37","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 Edg/96.0.1054.62","version":"23.0.0.10","exception":{"Exception":"Error","Message":"Undefined variable $userClients at /var/www/html/custom_apps/solid/lib/Controller/AppController.php#37","Code":0,"Trace":[{"file":"/var/www/html/custom_apps/solid/lib/Controller/AppController.php","line":37,"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::","args":[2,"Undefined variable $userClients","/var/www/html/custom_apps/solid/lib/Controller/AppController.php",37]},{"file":"/var/www/html/custom_apps/solid/lib/Controller/AppController.php","line":50,"function":"getUserApps","class":"OCA\\Solid\\Controller\\AppController","type":"->","args":["aa"]},{"file":"/var/www/html/custom_apps/solid/lib/Controller/AppController.php","line":77,"function":"getAppsList","class":"OCA\\Solid\\Controller\\AppController","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":217,"function":"appLauncher","class":"OCA\\Solid\\Controller\\AppController","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":126,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Solid\\Controller\\AppController","contactsManager":{"__class__":"OC\\ContactsManager"}},"appLauncher"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":157,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Solid\\Controller\\AppController","contactsManager":{"__class__":"OC\\ContactsManager"}},"appLauncher"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Solid\\Controller\\AppController","appLauncher",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"_route":"solid.app.appLauncher"}]},{"file":"/var/www/html/lib/base.php","line":1006,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/apps/solid/"]},{"file":"/var/www/html/index.php","line":36,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"},"id":"61cdd65e291f0"}

{"reqId":"MPLFyLESE9hEFsEbktAC","level":3,"time":"2021-12-30T15:55:09+00:00","remoteAddr":"172.18.0.3","user":"aa","app":"PHP","method":"GET","url":"/apps/solid/","message":"foreach() argument must be of type array|object, null given at /var/www/html/custom_apps/solid/lib/Controller/AppController.php#37","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 Edg/96.0.1054.62","version":"23.0.0.10","exception":{"Exception":"Error","Message":"foreach() argument must be of type array|object, null given at /var/www/html/custom_apps/solid/lib/Controller/AppController.php#37","Code":0,"Trace":[{"file":"/var/www/html/custom_apps/solid/lib/Controller/AppController.php","line":37,"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::","args":[2,"foreach() argument must be of type array|object, null given","/var/www/html/custom_apps/solid/lib/Controller/AppController.php",37]},{"file":"/var/www/html/custom_apps/solid/lib/Controller/AppController.php","line":50,"function":"getUserApps","class":"OCA\\Solid\\Controller\\AppController","type":"->","args":["aa"]},{"file":"/var/www/html/custom_apps/solid/lib/Controller/AppController.php","line":77,"function":"getAppsList","class":"OCA\\Solid\\Controller\\AppController","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":217,"function":"appLauncher","class":"OCA\\Solid\\Controller\\AppController","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":126,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Solid\\Controller\\AppController","contactsManager":{"__class__":"OC\\ContactsManager"}},"appLauncher"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":157,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Solid\\Controller\\AppController","contactsManager":{"__class__":"OC\\ContactsManager"}},"appLauncher"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Solid\\Controller\\AppController","appLauncher",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"_route":"solid.app.appLauncher"}]},{"file":"/var/www/html/lib/base.php","line":1006,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/apps/solid/"]},{"file":"/var/www/html/index.php","line":36,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"},"id":"61cdd65e29140"}

{"reqId":"MPLFyLESE9hEFsEbktAC","level":3,"time":"2021-12-30T15:55:09+00:00","remoteAddr":"172.18.0.3","user":"aa","app":"index","method":"GET","url":"/apps/solid/","message":"in_array(): Argument #2 ($haystack) must be of type array, string given in file '/var/www/html/custom_apps/solid/lib/Controller/AppController.php' line 55","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 Edg/96.0.1054.62","version":"23.0.0.10","exception":{"Exception":"Exception","Message":"in_array(): Argument #2 ($haystack) must be of type array, string given in file '/var/www/html/custom_apps/solid/lib/Controller/AppController.php' line 55","Code":0,"Trace":[{"file":"/var/www/html/lib/private/AppFramework/App.php","line":157,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Solid\\Controller\\AppController","contactsManager":{"__class__":"OC\\ContactsManager"}},"appLauncher"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Solid\\Controller\\AppController","appLauncher",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"_route":"solid.app.appLauncher"}]},{"file":"/var/www/html/lib/base.php","line":1006,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/apps/solid/"]},{"file":"/var/www/html/index.php","line":36,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","Line":158,"Previous":{"Exception":"TypeError","Message":"in_array(): Argument #2 ($haystack) must be of type array, string given","Code":0,"Trace":[{"file":"/var/www/html/custom_apps/solid/lib/Controller/AppController.php","line":55,"function":"in_array","args":[[],"notepod.vincenttunru.com"]},{"file":"/var/www/html/custom_apps/solid/lib/Controller/AppController.php","line":77,"function":"getAppsList","class":"OCA\\Solid\\Controller\\AppController","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":217,"function":"appLauncher","class":"OCA\\Solid\\Controller\\AppController","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":126,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Solid\\Controller\\AppController","contactsManager":{"__class__":"OC\\ContactsManager"}},"appLauncher"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":157,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Solid\\Controller\\AppController","contactsManager":{"__class__":"OC\\ContactsManager"}},"appLauncher"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Solid\\Controller\\AppController","appLauncher",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"_route":"solid.app.appLauncher"}]},{"file":"/var/www/html/lib/base.php","line":1006,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/apps/solid/"]},{"file":"/var/www/html/index.php","line":36,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/custom_apps/solid/lib/Controller/AppController.php","Line":55},"CustomMessage":"--"},"id":"61cdd65e29087"}

@Potherca
Copy link
Member

Hi! Thank you for taking the time to report this! Kudos for also diving into the code.

A certain kind of mind is certainly required when dealing with PHP. That's what we're here for, doing the PHP so you don't have to! 😁

Anyway, I've just taken a look at the code, both problems are developer mistakes. 😰

  • The $userClients error is a developer copy/paste mistake.
  • The $origin problem is caused by the needle and haystack being in the wrong order.

I've gone through the other controllers as a precaution and added fixes for some other potential bugs.
That should at least fix these issues, though others might be lurking deeper in the code.

Once #63 has been reviewed and merged, we need to deploy a release with those changes to the NC app store before you can start using them.

@Potherca Potherca self-assigned this Dec 31, 2021
@Potherca Potherca added the Type: Bug Something isn't working label Dec 31, 2021
@Potherca Potherca added this to the v0.4.3 milestone Dec 31, 2021
@Potherca Potherca linked a pull request Dec 31, 2021 that will close this issue
@Potherca Potherca moved this to Done in Solid Servers Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants