[Bug]: Restoring a file from trash loses version labels and authors, exposing named versions to expiration

Ouverte
#67,077 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
55/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
php
Domaine
backend, databases

Piste de recherche

Start by reading FileEventsListener.php around remove_hook() and deleteVersionsEntity(), then follow how LegacyVersionsBackend.php recreates version entries and how Trashbin.php restores files. Reproduce the steps with a named historical revision and compare its label and author before deletion and after restoration. Done means restoration preserves the revision contents, label, author, and expiration protection.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

0. Needs triage 35-feedback bug
⚠️ This issue respects the following points: ⚠️
  • This is not a troubleshooting question, general support matter, or webserver/proxy problem, but likely a bug (if unsure, ask the Community Help Forum).
  • This issue is not already reported on Github OR solved at the Community Help Forum (I've searched!).
  • I'm using a maintained major version of Nextcloud Server and tested against the latest patch level. (Supported major versions and current patch levels).
  • I agree to follow Nextcloud's Code of Conduct.
  • I've tried my best to provide clear reproduction steps that someone unfamiliar with this bug could use to reproduce it.
Bug description

Bug description

On Nextcloud Server 35.0.3, deleting a file from a shared folder and restoring it from trash preserves all revision contents but loses version labels and author metadata.

This is particularly important because named versions are excluded from automatic expiration. Losing a version label may expose a previously protected revision to automatic deletion under the configured retention policy.

Actual behavior

Property Before deletion After restoration
File ID 104149 104156
Number of revisions 3 3
Revision IDs Original Preserved
Revision contents Original Identical
Version timestamps Original Preserved
Named version Trash-probe-checkpoint null
Version authors mcp null

All three revisions were successfully read and compared before and after restoration.

Environment

  • Nextcloud Server 35.0.3
  • Nextcloud All-in-One
  • User-to-user shared folder
  • WebDAV client: nextcloud-mcp-server v0.226.3
  • versions_retention_obligation: "7, 30"
  • trashbin_retention_obligation: "90, 365"

Possible cause

In the current implementation, historical version files are moved to trash and subsequently restored.

However, FileEventsListener::remove_hook() calls deleteVersionsEntity(), while LegacyVersionsBackend::getVersionsForFile() can recreate missing version database entries with empty metadata.

This appears to explain why version contents survive while labels and authors are lost.

Relevant source files:

The loss of metadata was reproduced experimentally. Subsequent automatic expiration of a previously named revision is a potential consequence and has not yet been tested.

Related issues: #53152, #2103, #21567.

Steps to reproduce
  1. Create a text file in a folder shared by another local user.
  2. Modify the file twice to create three distinct revisions.
  3. Assign a name to one historical revision.
  4. Verify the version labels, authors and contents.
  5. Delete the file normally.
  6. Restore the file from trash using the same account.
  7. Compare the restored version history with its original state.
Expected behavior

Restoring a file from trash should preserve its historical revisions, including version labels and author metadata.

Named versions should retain their protection against automatic expiration.

Nextcloud Server version

35

Operating system

Other

PHP engine version

None

Web server

None

Database engine version

None

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

None

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?
  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other
Configuration report

List of activated Apps

Nextcloud Signing status

Nextcloud Logs

Additional info

No response

Langage dominant
PHP
Étoiles
37.6k
Forks
5.4k
Merge moyen
1 j 13 h
PR mergées (30 j)
623

Préparer son environnement

Ouvrir dans Codespaces

Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de nextcloud/server

Toutes les issues de nextcloud/server

Issues similaires

Plus d'issues PHP

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.