nextcloud / nextcloud/server

[Bug]: The CreateVersionEvent event of file versions is never fired

Open
#53,149 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage 31-feedback bug
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

⚠️ This issue respects the following points: ⚠️
Bug description

The CreateVersionEvent event is never triggered and is a behavior that is not even seen because there are no tests on it]:

https://github.com/search?q=repo%3Anextcloud%2Fserver%20CreateVersionEvent&type=code

https://github.com/search?q=repo%3Anextcloud%2Fserver+OCA%5CFiles_Versions%3A%3AcreateVersion&type=code

It is only triggered here:

https://github.com/nextcloud/server/blob/d03f6d804f723be6cc702df01a9bd0b81ae0f383/apps/files_versions/lib/Storage.php#L206

That Storage::store method is only called from here:

https://github.com/nextcloud/server/blob/d03f6d804f723be6cc702df01a9bd0b81ae0f383/apps/files_versions/lib/Listener/FileEventsListener.php#L175

The problem is that it always comes up here:

https://github.com/nextcloud/server/blob/d03f6d804f723be6cc702df01a9bd0b81ae0f383/apps/files_versions/lib/Listener/FileEventsListener.php#L171

Why write_hook is called from here:

https://github.com/nextcloud/server/blob/d03f6d804f723be6cc702df01a9bd0b81ae0f383/apps/files_versions/lib/Listener/FileEventsListener.php#L80

And the node is of type NonExistingFile always...

Steps to reproduce
  1. Be subscribed in an app to the CreateVersionEvent event (or put a log here).
  2. Upload a file through the UI or through WebDav
  3. Check that it never arrives and always goes out here

It also occurs when copying or moving files or folders with files in it

Expected behavior

The event should be launched

Nextcloud Server version

31

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.3

Web server

Nginx

Database engine version

None

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?
  • 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in apps/files_versions/lib/Listener/FileEventsListener.php, following the write_hook path around the reported lines and the NonExistingFile handling. Then inspect apps/files_versions/lib/Storage.php and Events/CreateVersionEvent.php to trace when the event is dispatched during uploads, copies, and moves. Done means the event is fired for these file-version operations and coverage is added for the previously untested behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.