nextcloud / server

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

Cannot access files after upgrade #27881

Closed jzombi closed 3 years ago

jzombi commented 3 years ago

How to use GitHub

Steps to reproduce

  1. Log in to nextcloud web interface
  2. Navigate to files https://<nextcloud_domain>/apps/files/

Expected behaviour

See the list of files

Actual behaviour

Got the following message:

This directory is unavailable, please check the logs or contact the administrator

Server configuration

Operating system: Linux [...] 5.12.3-arch1-1 #1 SMP PREEMPT [...] x86_64 GNU/Linux (Arch linux)

Web server: nginx/1.20.0

Database: PostgreSQL 13.2

PHP version: 7.4.18

Nextcloud version: (see Nextcloud admin page) 22.0.0

Updated from an older Nextcloud/ownCloud or fresh install: Just updated from 21.0.1

Where did you install Nextcloud from: https://download.nextcloud.com/server/releases/nextcloud-22.0.0.zip

Signing status:

Signing status ``` No errors have been found. ```

List of activated apps:

App list ``` Enabled: - accessibility: 1.7.0 - activity: 2.15.0 - admin_audit: 1.11.0 - calendar: 2.3.0 - circles: 22.0.0 - cloud_federation_api: 1.4.0 - comments: 1.11.0 - contacts: 4.0.0 - contactsinteraction: 1.2.0 - dashboard: 7.1.0 - dav: 1.18.0 - federatedfilesharing: 1.11.0 - federation: 1.11.0 - files: 1.16.0 - files_pdfviewer: 2.3.0 - files_rightclick: 1.1.0 - files_sharing: 1.13.2 - files_trashbin: 1.11.0 - files_versions: 1.14.0 - files_videoplayer: 1.11.0 - firstrunwizard: 2.11.0 - logreader: 2.7.0 - lookup_server_connector: 1.9.0 - nextcloud_announcements: 1.11.0 - notifications: 2.10.1 - oauth2: 1.9.0 - password_policy: 1.12.0 - photos: 1.4.0 - privacy: 1.6.0 - provisioning_api: 1.11.0 - recommendations: 1.1.0 - serverinfo: 1.12.0 - settings: 1.3.0 - sharebymail: 1.11.0 - spreed: 12.0.0 - support: 1.5.0 - survey_client: 1.10.0 - systemtags: 1.11.0 - text: 3.3.0 - theming: 1.12.0 - twofactor_backupcodes: 1.10.1 - updatenotification: 1.11.0 - user_status: 1.1.1 - viewer: 1.6.0 - weather_status: 1.1.0 - workflowengine: 2.3.0 Disabled: - encryption - files_external - tasks - user_ldap ```

Nextcloud configuration:

Config report ``` { "system": { "instanceid": "***REMOVED SENSITIVE VALUE***", "passwordsalt": "***REMOVED SENSITIVE VALUE***", "secret": "***REMOVED SENSITIVE VALUE***", "trusted_domains": [ "***REMOVED***" ], "auth.bruteforce.protection.enabled": false, "datadirectory": "***REMOVED SENSITIVE VALUE***", "overwrite.cli.url": "***REMOVED***", "dbtype": "pgsql", "version": "22.0.0.11", "dbname": "***REMOVED SENSITIVE VALUE***", "dbhost": "***REMOVED SENSITIVE VALUE***", "dbtableprefix": "oc_", "dbuser": "***REMOVED SENSITIVE VALUE***", "dbpassword": "***REMOVED SENSITIVE VALUE***", "installed": true, "default_phone_region": "HU", "mail_smtpmode": "smtp", "mail_smtpsecure": "tls", "mail_from_address": "***REMOVED SENSITIVE VALUE***", "mail_domain": "***REMOVED SENSITIVE VALUE***", "mail_smtpauthtype": "PLAIN", "mail_smtpauth": 1, "mail_smtphost": "***REMOVED SENSITIVE VALUE***", "mail_smtpport": "587", "mail_smtpname": "***REMOVED SENSITIVE VALUE***", "mail_smtppassword": "***REMOVED SENSITIVE VALUE***", "memcache.local": "\\OC\\Memcache\\APCu", "loglevel": 0, "maintenance": false, "theme": "", "asset-pipeline.enabled": false, "trashbin_retention_obligation": "auto", "htaccess.RewriteBase": "\/nextcloud", "app_install_overwrite": [ "calendar" ], "updater.release.channel": "stable" } } ```

Are you using external storage, if yes which one: local

Are you using encryption: no

Are you using an external user-backend, if yes which one: no

Client configuration

Browser: Brave Browser 91.1.26.67

Operating system: Linux [...] 5.11.16-arch1-1 #1 SMP PREEMPT [...] x86_64 GNU/Linux (Arch linux)

Logs

Nextcloud log (data/nextcloud.log)

Nextcloud log ``` {"reqId":"[...]","level":4,"time":"2021-07-08T21:27:20+00:00","remoteAddr":"192.168.1.1","user":"jzombi","app":"webdav","method":"PROPFIND","url":"/nextcloud/remote.php/dav/files/jzombi/","message":"An exception occurred while executing a query: SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: character varying = integer\nLINE 1: ...ERE (\"c\".\"object_type\" = $2) AND (\"c\".\"object_id\" IN ($3, $4...\n ^\nHINT: No operator matches the given name and argument types. You might need to add explicit type casts.","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36","version":"22.0.0.11","exception":{"Exception":"OC\\DB\\Exceptions\\DbalException","Message":"An exception occurred while executing a query: SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: character varying = integer\nLINE 1: ...ERE (\"c\".\"object_type\" = $2) AND (\"c\".\"object_id\" IN ($3, $4...\n ^\nHINT: No operator matches the given name and argument types. You might need to add explicit type casts.","Code":7,"Trace":[{"file":"[...]/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":302,"function":"wrap","class":"OC\\DB\\Exceptions\\DbalException","type":"::","args":[{"__class__":"Doctrine\\DBAL\\Exception\\DriverException"}]},{"file":"[...]/nextcloud/lib/private/Comments/Manager.php","line":661,"function":"executeQuery","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->","args":[]},{"file":"[...]/nextcloud/apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php","line":88,"function":"getNumberOfUnreadCommentsForObjects","class":"OC\\Comments\\Manager","type":"->","args":["files",["26798","25952","42902","174816","195426","215845","151","195420","176794","170399","185868","780","208924","41","37","216722","217905","59","21684","48539","279343","36"],{"__class__":"OC\\User\\User"}]},{"file":"[...]/nextcloud/apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php","line":116,"function":"cacheDirectory","class":"OCA\\DAV\\Connector\\Sabre\\CommentPropertiesPlugin","type":"->","args":[{"__class__":"OCA\\DAV\\Files\\FilesHome"}]},{"file":"[...]/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"handleGetProperties","class":"OCA\\DAV\\Connector\\Sabre\\CommentPropertiesPlugin","type":"->","args":[{"__class__":"Sabre\\DAV\\PropFind"},{"__class__":"OCA\\DAV\\Files\\FilesHome"}]},{"file":"[...]/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":1052,"function":"emit","class":"Sabre\\DAV\\Server","type":"->","args":["propFind",[{"__class__":"Sabre\\DAV\\PropFind"},{"__class__":"OCA\\DAV\\Files\\FilesHome"}]]},{"file":"[...]/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":984,"function":"getPropertiesByNode","class":"Sabre\\DAV\\Server","type":"->","args":[{"__class__":"Sabre\\DAV\\PropFind"},{"__class__":"OCA\\DAV\\Files\\FilesHome"}]},{"file":"[...]/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":1661,"function":"getPropertiesIteratorForPath","class":"Sabre\\DAV\\Server","type":"->","args":["files/jzombi",["{DAV:}getlastmodified","{DAV:}getetag","{DAV:}getcontenttype","{DAV:}resourcetype","{http://owncloud.org/ns}fileid","{http://owncloud.org/ns}permissions","{http://owncloud. org/ns}size","{DAV:}getcontentlength","{DAV:}quota-available-bytes","{http://nextcloud.org/ns}has-preview","{http://nextcloud.org/ns}mount-type","{http://nextcloud.org/ns}is-encrypted","{http://open-collaboration-services.org/ns}share-permissions","{http://owncloud.org/ns}tags","{http://owncloud.org/ns}favorite","{http://owncloud.org/ns}comments-unread","{http://owncloud.org/ns}owner-id","{http://owncloud.org/ns}owner-display-name","{http://owncloud.org/ns}share-types"],1]},{"file":"[...]/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":1646,"function":"writeMultiStatus","class":"Sabre\\DAV\\Server","type":"->","args":[{"elementMap":[],"contextUri":"/nextcloud/remote.php/dav/","namespaceMap":{"DAV:":"d","http://sabredav.org/ns":"s","http://owncloud.org/ns":"oc","http://nextcloud.org/ns":"nc"},"classMap":[],"__class__":"Sabre\\Xml\\Writer"},{"__class__":"Generator"},false]},{"file":"[...]/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":346,"function":"generateMultiStatus","class":"Sabre\\DAV\\Server","type":"->","args":[{"__class__":"Generator"},false]},{"file":"[...]/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpPropFind","class":"Sabre\\DAV\\CorePlugin","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"[...]/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":472,"function":"emit","class":"Sabre\\DAV\\Server","type":"->","args":["method:PROPFIND",[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"[...]/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":253,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"[...]/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":321,"function":"start","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"[...]/nextcloud/apps/dav/lib/Server.php","line":332,"function":"exec","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"[...]/nextcloud/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->","args":[]}, {"file":"[...]/nextcloud/remote.php","line":166,"args":["[...]/nextcloud/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"[...]/nextcloud/lib/private/DB/Exceptions/DbalException.php","Line":71,"Previous":{"Exception":"Doctrine\\DBAL\\Exception\\DriverException","Message":"An exception occurred while executing a query: SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: character varying = integer\n ```

Workaround

The problem seems to be caused by this query: https://github.com/nextcloud/server/blob/dad31ce3fa7085769b87309141c250c5865994b4/lib/private/Comments/Manager.php#L635-L669

The object_id column of oc_comments table is of type character varying(64), and it is tested against an integer array (IQueryBuilder::PARAM_INT_ARRAY). Changing the following line: https://github.com/nextcloud/server/blob/dad31ce3fa7085769b87309141c250c5865994b4/lib/private/Comments/Manager.php#L659 to

$query->setParameter('ids', $chunk, IQueryBuilder::PARAM_STR_ARRAY);

seems to solve the issue, the files appear on the nextcloud web interface.

jzombi commented 3 years ago

Most probably this commit introduced the problem: https://github.com/nextcloud/server/commit/a50eba16adbee809ce69806ee5baee30707b8cca

plexxman commented 3 years ago

I can confirm the issue and the workaround provided works perfectly, changing the query in Manager.php solves the problem.

plexxman commented 3 years ago

Update: Changed to nextcloud/docker/latest (using Apache), and the problem was solved without needing the query change.

szaimen commented 3 years ago

Based on plexxman's comment I am closing this. Feel free to reopen this if you should still experience this on NC22.1.0

jzombi commented 3 years ago

The issue is still present in 22.1.0 (manually upgraded from 22.0). The above workaround still works.

@szaimen could you reopen the issue? I can't see any button for this. Sorry for the trouble, I'm not an experienced github user.

szaimen commented 3 years ago

@jzombi Thanks for answering! Do you mind opening a PR with your mentioned patch for discussion? Thank you!