nextcloud / server

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

[Bug]: Fail to create new files because of Call to undefined method OC\\Files\\Node\\File::searchByMime() #49436

Open daufinsyd opened 20 hours ago

daufinsyd commented 20 hours ago

⚠️ This issue respects the following points: ⚠️

Bug description

Hello when trying to create a new file (ex text file / doc file ...) nothing happens and nextcloud throws the following error:

{"reqId":"h5k7LOexgBoW8yf5Z9y1","level":3,"time":"2024-11-21T17:48:22+00:00","remoteAddr":"192.168.0.199","user":"2b7f8d58-ff30-103a-9269-8938486928c8","app":"no app in context","method":"GET","url":"/ocs/v2.php/apps/files/api/v1/templates","message":"Call to undefined method OC\\Files\\Node\\File::searchByMime() in file '/va
r/www/html/lib/private/Files/Template/TemplateManager.php' line 198","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:132.0) Gecko/20100101 Firefox/132.0","version":"30.0.2.2","exception":{"Exception":"Exception","Message":"Call to undefined method OC\\Files\\Node\\File::searchByMime() in file '/var/www/html/lib/
private/Files/Template/TemplateManager.php' line 198","Code":0,"Trace":[{"file":"/var/www/html/lib/private/AppFramework/App.php","line":161,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Files\\Controller\\TemplateController"},"list"]},{"file":"/var/www/html/lib/priva
te/Route/Router.php","line":302,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Files\\Controller\\TemplateController","list",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"_route":"ocs.files.template.list"}]},{"file":"/var/www/html/ocs/v1.php","line":43,"function":"match","cl
ass":"OC\\Route\\Router","type":"->","args":["/ocsapp/apps/files/api/v1/templates"]},{"file":"/var/www/html/ocs/v2.php","line":7,"args":["/var/www/html/ocs/v1.php"],"function":"require_once"}],"File":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","Line":146,"Previous":{"Exception":"Error","Message":"Call to unde
fined method OC\\Files\\Node\\File::searchByMime()","Code":0,"Trace":[{"file":"/var/www/html/lib/private/Files/Template/TemplateManager.php","line":123,"function":"getTemplateFiles","class":"OC\\Files\\Template\\TemplateManager","type":"->","args":["*** sensitive parameters replaced ***"]},{"function":"OC\\Files\\Template\\{c
losure}","class":"OC\\Files\\Template\\TemplateManager","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/lib/private/Files/Template/TemplateManager.php","line":121,"function":"array_map","args":[{"__class__":"Closure"},["*** sensitive parameters replaced ***","*** sensitive parameters repla
ced ***","*** sensitive parameters replaced ***","*** sensitive parameters replaced ***"]]},{"file":"/var/www/html/apps/files/lib/Controller/TemplateController.php","line":44,"function":"listTemplates","class":"OC\\Files\\Template\\TemplateManager","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppFramework/Http/Di
spatcher.php","line":208,"function":"list","class":"OCA\\Files\\Controller\\TemplateController","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":114,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Files\\Contro
ller\\TemplateController"},"list"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":161,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Files\\Controller\\TemplateController"},"list"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":302,"fun
ction":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Files\\Controller\\TemplateController","list",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"_route":"ocs.files.template.list"}]},{"file":"/var/www/html/ocs/v1.php","line":43,"function":"match","class":"OC\\Route\\Router","type":"->"
,"args":["/ocsapp/apps/files/api/v1/templates"]},{"file":"/var/www/html/ocs/v2.php","line":7,"args":["/var/www/html/ocs/v1.php"],"function":"require_once"}],"File":"/var/www/html/lib/private/Files/Template/TemplateManager.php","Line":198},"message":"Call to undefined method OC\\Files\\Node\\File::searchByMime() in file '/var/
www/html/lib/private/Files/Template/TemplateManager.php' line 198","exception":{},"CustomMessage":"Call to undefined method OC\\Files\\Node\\File::searchByMime() in file '/var/www/html/lib/private/Files/Template/TemplateManager.php' line 198"}}

The server responds with a HTTP500 to ocs/v2.php/apps/files/api/v1/templates

Creating folder or files from other app (eg. drawio files) does work.

Steps to reproduce

  1. create a new file from nextcloud webui
  2. nothing happens

Expected behavior

The desired file is created.

Nextcloud Server version

30

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.2

Web server

Apache (supported)

Database engine version

PostgreSQL

Is this bug present after an update or on a fresh install?

Upgraded to a MAJOR version (ex. 28 to 29)

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

Configuration report

{
    "system": {
        "debug": false,
        "htaccess.RewriteBase": "\/",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "password": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "192.168.0.2",
            "cloud.my.domain"
        ],
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "pgsql",
        "version": "30.0.2.2",
        "overwrite.cli.url": "https:\/\/cloud.my.domain",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "ldapIgnoreNamingRules": false,
        "ldapProviderFactory": "OCA\\User_LDAP\\LDAPProviderFactory",
        "overwriteprotocol": "https",
        "maintenance": false,
        "app.mail.verify-tls-peer": false,
        "loglevel": 2,
        "memories.exiftool": "\/var\/www\/html\/nextcloud\/custom_apps\/memories\/bin-ext\/exiftool-amd64-glibc",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_sendmailmode": "smtp",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpauthtype": "LOGIN",
        "mail_smtpauth": 1,
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpsecure": "ssl",
        "mail_smtpport": "465",
        "updater.release.channel": "stable",
        "memories.vod.path": "\/var\/www\/html\/nextcloud\/custom_apps\/memories\/bin-ext\/go-vod-amd64",
        "memories.vod.ffmpeg": "\/usr\/bin\/ffmpeg",
        "memories.vod.ffprobe": "\/usr\/bin\/ffprobe",
        "theme": "",
        "enable_previews": true,
        "enabledPreviewProviders": [
            "OC\\Preview\\TXT",
            "OC\\Preview\\MarkDown",
            "OC\\Preview\\OpenDocument",
            "OC\\Preview\\PDF",
            "OC\\Preview\\MSOffice2003",
            "OC\\Preview\\MSOfficeDoc",
            "OC\\Preview\\Image",
            "OC\\Preview\\Photoshop",
            "OC\\Preview\\TIFF",
            "OC\\Preview\\SVG",
            "OC\\Preview\\Font",
            "OC\\Preview\\MP3",
            "OC\\Preview\\Movie",
            "OC\\Preview\\MKV",
            "OC\\Preview\\MP4",
            "OC\\Preview\\AVI"
        ],
        "app_install_overwrite": [
            "drawio",
            "memories",
            "metadata",
            "files_rightclick"
        ],
        "memories.gis_type": 2,
        "memories.db.triggers.fcu": true,
        "maintenance_window_start": 1,
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "upgrade.disable-web": true
    }
}

List of activated Apps

Enabled:
  - activity: 3.0.0
  - app_api: 4.0.0
  - assistant: 2.1.1
  - bruteforcesettings: 3.0.0
  - calendar: 5.0.1
  - cfg_share_links: 6.1.1
  - circles: 30.0.0
  - cloud_federation_api: 1.13.0
  - collectives: 2.15.0
  - comments: 1.20.1
  - contacts: 6.1.1
  - contactsinteraction: 1.11.0
  - cookbook: 0.11.2
  - dav: 1.31.1
  - deck: 1.14.2
  - drawio: 3.0.3
  - external: 5.5.2
  - federatedfilesharing: 1.20.0
  - files: 2.2.0
  - files_downloadlimit: 3.0.0
  - files_external: 1.22.0
  - files_pdfviewer: 3.0.0
  - files_reminders: 1.3.0
  - files_sharing: 1.22.0
  - files_trashbin: 1.20.1
  - files_versions: 1.23.0
  - fileslibreofficeedit: 2.0.1
  - firstrunwizard: 3.0.0
  - integration_openstreetmap: 2.0.1
  - logreader: 3.0.0
  - lookup_server_connector: 1.18.0
  - mail: 4.0.2
  - memories: 7.4.1
  - metadata: 0.21.0
  - nextcloud_announcements: 2.0.0
  - notes: 4.11.0
  - notifications: 3.0.0
  - oauth2: 1.18.1
  - password_policy: 2.0.0
  - photos: 3.0.2
  - previewgenerator: 5.7.0
  - privacy: 2.0.0
  - provisioning_api: 1.20.0
  - recognize: 8.1.1
  - recommendations: 3.0.0
  - related_resources: 1.5.0
  - richdocuments: 8.5.2
  - richdocumentscode: 24.4.902
  - serverinfo: 2.0.0
  - settings: 1.13.0
  - sharebymail: 1.20.0
  - spreed: 20.0.2
  - support: 2.0.0
  - survey_client: 2.0.0
  - systemtags: 1.20.0
  - tables: 0.8.1
  - tasks: 0.16.1
  - text: 4.1.0
  - theming: 2.5.0
  - twofactor_backupcodes: 1.19.0
  - updatenotification: 1.20.0
  - user_ldap: 1.21.0
  - user_status: 1.10.0
  - viewer: 3.0.0
  - webhook_listeners: 1.1.0-dev
  - workflowengine: 2.12.0
Disabled:
  - admin_audit: 1.20.0
  - cospend: 2.0.0 (installed 2.0.0)
  - dashboard: 7.10.0 (installed 7.9.0)
  - encryption: 2.18.0
  - end_to_end_encryption: 1.16.1 (installed 1.16.1)
  - federation: 1.20.0 (installed 1.14.0)
  - files_linkeditor: 1.1.21 (installed 1.1.21)
  - files_rightclick: 0.15.1 (installed 0.15.1)
  - integration_openai: 3.1.2 (installed 3.1.2)
  - maps: 1.5.0 (installed 1.5.0)
  - music: 2.0.1 (installed 2.0.1)
  - suspicious_login: 8.0.0
  - twofactor_nextcloud_notification: 4.0.0
  - twofactor_totp: 12.0.0-dev
  - weather_status: 1.10.0 (installed 1.1.0)

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

{"reqId":"h5k7LOexgBoW8yf5Z9y1","level":3,"time":"2024-11-21T17:48:22+00:00","remoteAddr":"192.168.0.199","user":"2b7f8d58-ff30-103a-9269-8938486928c8","app":"no app in context","method":"GET","url":"/ocs/v2.php/apps/files/api/v1/templates","message":"Call to undefined method OC\\Files\\Node\\File::searchByMime() in file '/va
r/www/html/lib/private/Files/Template/TemplateManager.php' line 198","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:132.0) Gecko/20100101 Firefox/132.0","version":"30.0.2.2","exception":{"Exception":"Exception","Message":"Call to undefined method OC\\Files\\Node\\File::searchByMime() in file '/var/www/html/lib/
private/Files/Template/TemplateManager.php' line 198","Code":0,"Trace":[{"file":"/var/www/html/lib/private/AppFramework/App.php","line":161,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Files\\Controller\\TemplateController"},"list"]},{"file":"/var/www/html/lib/priva
te/Route/Router.php","line":302,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Files\\Controller\\TemplateController","list",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"_route":"ocs.files.template.list"}]},{"file":"/var/www/html/ocs/v1.php","line":43,"function":"match","cl
ass":"OC\\Route\\Router","type":"->","args":["/ocsapp/apps/files/api/v1/templates"]},{"file":"/var/www/html/ocs/v2.php","line":7,"args":["/var/www/html/ocs/v1.php"],"function":"require_once"}],"File":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","Line":146,"Previous":{"Exception":"Error","Message":"Call to unde
fined method OC\\Files\\Node\\File::searchByMime()","Code":0,"Trace":[{"file":"/var/www/html/lib/private/Files/Template/TemplateManager.php","line":123,"function":"getTemplateFiles","class":"OC\\Files\\Template\\TemplateManager","type":"->","args":["*** sensitive parameters replaced ***"]},{"function":"OC\\Files\\Template\\{c
losure}","class":"OC\\Files\\Template\\TemplateManager","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/lib/private/Files/Template/TemplateManager.php","line":121,"function":"array_map","args":[{"__class__":"Closure"},["*** sensitive parameters replaced ***","*** sensitive parameters repla
ced ***","*** sensitive parameters replaced ***","*** sensitive parameters replaced ***"]]},{"file":"/var/www/html/apps/files/lib/Controller/TemplateController.php","line":44,"function":"listTemplates","class":"OC\\Files\\Template\\TemplateManager","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppFramework/Http/Di
spatcher.php","line":208,"function":"list","class":"OCA\\Files\\Controller\\TemplateController","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":114,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Files\\Contro
ller\\TemplateController"},"list"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":161,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Files\\Controller\\TemplateController"},"list"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":302,"fun
ction":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Files\\Controller\\TemplateController","list",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"_route":"ocs.files.template.list"}]},{"file":"/var/www/html/ocs/v1.php","line":43,"function":"match","class":"OC\\Route\\Router","type":"->"
,"args":["/ocsapp/apps/files/api/v1/templates"]},{"file":"/var/www/html/ocs/v2.php","line":7,"args":["/var/www/html/ocs/v1.php"],"function":"require_once"}],"File":"/var/www/html/lib/private/Files/Template/TemplateManager.php","Line":198},"message":"Call to undefined method OC\\Files\\Node\\File::searchByMime() in file '/var/
www/html/lib/private/Files/Template/TemplateManager.php' line 198","exception":{},"CustomMessage":"Call to undefined method OC\\Files\\Node\\File::searchByMime() in file '/var/www/html/lib/private/Files/Template/TemplateManager.php' line 198"}}

Additional info

The error appeared with nextcloud 30 as far as I can remember. Updating to 30.0.1 and 30.0.2 didn't help.

sha1sum /var/www/html/lib/private/Files/Template/TemplateManager.php
cd255660acd4163c70752a8252291df135765893  /var/www/html/lib/private/Files/Template/TemplateManager.php
joshtrichards commented 18 hours ago

What is the templateDirectory set to for your account? e.g.

occ user:setting <account> core templateDirectory

And is it a folder within that account? e.g.

ls data//files/

daufinsyd commented 4 hours ago

Hi, thank your for your response. Indeed the output pointed to some md file

/gmi/news (+202) old project.md

honestly I have no idea how it happened in the first place, given I wasn't even aware such a command exists.

Setting it to empty solved the issue occ user:setting <account> core templateDirectory ''

It would be really nice if nextcloud handled such error in a more user friendly way, so that the user knows from the ui when creating new files, that the template dir is incorrect or something (instead of doing nothing but raising this error in the logs)