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]: Node is not deleted from trashbin table upon permanent deletion. #49430

Open redblom opened 23 hours ago

redblom commented 23 hours ago

⚠️ This issue respects the following points: ⚠️

Bug description

Bug: When a file or folder is permanently deleted from the trashbin (through the GUI) the corresponding file/folder entry is not removed from the database trashbin table.

Cause: In the static function apps/files_trashbin/lib/Trashbin.php delete($filename, $user, $timestamp = null) the filename parameter always seems to carry a leading '/' (at least I have not seen otherwise). The id of the item in trashbin the table however does not carry this leading '/'. Hence the item is not removed from the table.

(note that: filecache items are removed and the file/folder is actually removed from the storage/file-system)

Other observation: In my case I'm developing an app that makes use of the Trashbin permanentDelete hook. When the permanentDelete(array $params) method in that hook is called, the path entry in params has as value a path with a double forward slash in it. Eg. ['path' => '/files_trashbin/files//text.txt.d1731917455']

Both this observation and the bug cause seem to stem from the fact that the apps/files_trashbin/lib/Trash/TrashItem.php getTrashPath() function always returns the path with a leading / and that in the call chain no further processing is performed on this slash.

Steps to reproduce

  1. Delete a file or folder from within the GUI
  2. Navigate to trashbin and permanently delete the file or folder
  3. Observe that the file/folder entry is not removed from the database trashbin table

Expected behavior

The file/folder entry is removed from the trashbin table.

Nextcloud Server version

30

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.2

Web server

Apache (supported)

Database engine version

MariaDB

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

Fresh Nextcloud Server install

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?

Configuration report

{
    "system": {
        "htaccess.RewriteBase": "\/",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "upgrade.disable-web": true,
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "30.0.1.2",
        "overwrite.cli.url": "http:\/\/localhost",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "loglevel": 0,
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "overwritehost": "nc-1.nl",
        "overwriteprotocol": "https"
    }
}

List of activated Apps

Enabled:
  - activity: 3.0.0
  - app_api: 4.0.0
  - bruteforcesettings: 3.0.0
  - cloud_federation_api: 1.13.0
  - comments: 1.20.1
  - contactsinteraction: 1.11.0
  - dashboard: 7.10.0
  - dav: 1.31.1
  - federatedfilesharing: 1.20.0
  - federation: 1.20.0
  - files: 2.2.0
  - files_downloadlimit: 3.0.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
  - firstrunwizard: 3.0.0
  - logreader: 3.0.0
  - lookup_server_connector: 1.18.0
  - nextcloud_announcements: 2.0.0
  - notifications: 3.0.0
  - oauth2: 1.18.1
  - password_policy: 2.0.0
  - photos: 3.0.2
  - privacy: 2.0.0
  - provisioning_api: 1.20.0
  - recommendations: 3.0.0
  - related_resources: 1.5.0
  - serverinfo: 2.0.0
  - settings: 1.13.0
  - sharebymail: 1.20.0
  - support: 2.0.0
  - survey_client: 2.0.0
  - systemtags: 1.20.0
  - text: 4.1.0
  - theming: 2.5.0
  - twofactor_backupcodes: 1.19.0
  - updatenotification: 1.20.0
  - user_status: 1.10.0
  - viewer: 3.0.0
  - weather_status: 1.10.0
  - webhook_listeners: 1.1.0-dev
  - workflowengine: 2.12.0
Disabled:
  - admin_audit: 1.20.0
  - circles: 30.0.0-dev (installed 30.0.0-dev)
  - encryption: 2.18.0
  - files_external: 1.22.0
  - suspicious_login: 8.0.0
  - twofactor_nextcloud_notification: 4.0.0
  - twofactor_totp: 12.0.0-dev
  - user_ldap: 1.21.0

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

No logging relevant to this issue found.

Additional info

Environment: . Nextcloud docker image nextcloud:30.0.1 . MariaDB docker image mariadb:10.9