nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
27.44k stars 4.08k forks source link

Dropbox apps fails with Internal Server Error if External storage support is not enabled #21025

Closed ismailyenigul closed 4 years ago

ismailyenigul commented 4 years ago

Steps to reproduce

  1. Create a nextcloud container Login as admin
  2. Go to the apps-> Files and enable External Storage backend for Dropbox app
  3. Then you will get Internal Server Error

Expected behaviour

nextcloud should not enable any external storage app if External Storage backend is not enabled. If I enable External Storage backend then enable other Files apps it works fine because oc_external_mounts will be created by enabling featured app 'External Storage backend'

Actual behaviour

It tries to enable External Storage backend for Dropbox app without checking whether oc_external_mounts db tables exist or not than returns Internal Server Error

Server configuration

Operating system: Docker 18.04 image from dockerhub

Nextcloud version: (see Nextcloud admin page) 18.4.2 Updated from an older Nextcloud/ownCloud or fresh install: Fresh install Where did you install Nextcloud from: deployed with docker-compose

Logs

{"reqId":"bUYWWk8ohx8tAg1pRYvK","level":3,"time":"2020-05-17T23:23:29+00:00","remoteAddr":"82.7.101.128","user":"admin","app":"no app in context","method":"GET","url":"/ocs/v2.php/core/navigation/apps?format=json","message":{"Exception":"Doctrine\DBAL\Exception\TableNotFoundException","Message":"An exception occurred while executing 'SELECT \"m\".\"mount_id\", \"mount_point\", \"storage_backend\", \"auth_backend\", \"priority\", \"m\".\"type\" FROM \"oc_external_mounts\" \"m\" INNER JOIN \"oc_external_applicable\" \"a\" ON \"m\".\"mount_id\" = \"a\".\"mount_id\" WHERE ((\"a\".\"type\" = ?) AND (\"a\".\"value\" IS NULL)) OR ((\"a\".\"type\" = ?) AND (\"a\".\"value\" = ?)) OR ((\"a\".\"type\" = ?) AND (\"a\".\"value\" IN (?)))' with params [1, 3, \"admin\", 2, \"admin\"]:\n\nSQLSTATE[42P01]: Undefined table: 7 ERROR: relation \"oc_external_mounts\" does not exist\nLINE 1: ...end\", \"auth_backend\", \"priority\", \"m\".\"type\" FROM \"oc_extern...\n

kesselb commented 4 years ago

Should be fixed by https://github.com/DJaeger/files_external_dropbox/commit/d01d2fea2ffbcda82524a7bc5f58743929111ea8

ismailyenigul commented 4 years ago

I already use External Storage backend for Dropbox 1.4.0 btw I installed some other extentions. I will verify which others could break too.

ismailyenigul commented 4 years ago

ok here is more details.

  1. files_external and files_external_dropbox are disabled and there is no oc_external_* tables. I just enabled files_external_dropbox and got Internal error. When I check enabled apps, I can see that files_external and files_external_dropbox enabled but oc_external_* tables weren't created.
www-data@ef6a0f1adb67:~/html$ php occ app:list  |more
Enabled:
  .... 
 - federation: 1.8.0
  - files: 1.13.1
  - files_external: 1.9.0
  - files_external_dropbox: 1.4.0
  - files_pdfviewer: 1.7.0
nextcloud=# \dt
                    List of relations
 Schema |            Name             | Type  |  Owner   
--------+-----------------------------+-------+----------
 ...
 public | oc_credentials              | table | oc_admin
 public | oc_dav_cal_proxy            | table | oc_admin
 public | oc_dav_shares               | table | oc_admin
 public | oc_direct_edit              | table | oc_admin
 public | oc_directlink               | table | oc_admin
 public | oc_federated_reshares       | table | oc_admin
 public | oc_file_locks               | table | oc_admin
 public | oc_filecache                | table | oc_admin
 public | oc_filecache_extended       | table | oc_admin
 public | oc_files_trash              | table 

It seems \OC::$server->getAppManager()->enableApp('files_external'); at https://github.com/DJaeger/files_external_dropbox/commit/d01d2fea2ffbcda82524a7bc5f58743929111ea8#diff-079bbe455bfa9aeaf363ae1bc6415ba0R27 does not create tables somehow.

Summary: Enabling files_external creates tables successfully but not via \OC::$server->getAppManager()->enableApp('files_external');

kesselb commented 4 years ago

Yep. OC_App::enable would be the right method.

kesselb commented 4 years ago

Closing this issue. The app management does not have a feature to manage app dependencies. That needs to be implemented by the apps itself.

OC_App::enable is the method to enable a app and run the installation routine.

cc @DJaeger