Skip to content

fix: hardening for opcache.enable_file_override#734

Merged
Altahrim merged 1 commit intomasterfrom
fix/harden-for-enable_file_override
Apr 7, 2026
Merged

fix: hardening for opcache.enable_file_override#734
Altahrim merged 1 commit intomasterfrom
fix/harden-for-enable_file_override

Conversation

@MichaIng
Copy link
Copy Markdown
Member

@MichaIng MichaIng commented Apr 4, 2026

If the PHP instance has aggressive caching enabled, with opcache.enable_file_override and sufficiently long or disabled opcache.validate_timestamps, file_exists($versionFileName) can retrun true after the file was removed from disk in the respective updater step. require_once $versionFileName; however requires the file to exist on disk, even if it has an OPcache entry.

With this commit, the cache entry is invalidated before file_exists($versionFileName) is called, to harden the updater for instances with opcache.enable_file_override.

Alternatives to this approach:

  1. Always read the version string from config.php. But I am not sure about possible implications, e.g. for the updater steps after files were moved in place, where currently the new version string is used, while config.php contains the old version string.
  2. Be more explicit about when to use version.php and when to use config.php: use config.php only explicitly after old files were removed, and before new files were moved in place, otherwise require version.php. However, this is surely more complex to implement, and it is less flexible to handle aborted and reset updates, e.g. when the current step flag has been removed. Only after the step of moving new files in place, version.php can be relied on without causing a regression.
  3. Require opcache.enable_file_override=0, but as a caching enthusiast I would be sad if I needed to reintroduce additional disk hits.

@MichaIng MichaIng added this to the Nextcloud 34 milestone Apr 4, 2026
@MichaIng MichaIng linked an issue Apr 4, 2026 that may be closed by this pull request
8 tasks
@MichaIng MichaIng force-pushed the fix/harden-for-enable_file_override branch 2 times, most recently from c342721 to 0678abf Compare April 4, 2026 13:22
If the PHP instance has aggressive caching enabled, with `opcache.enable_file_override` and sufficiently long or disabled `opcache.validate_timestamps`, `file_exists($versionFileName)` can retrun true after the file was removed from disk. `require_once $versionFileName;` however requires the file to exist on disk, even if it has an OPcache entry.

With this commit, the cache entry is invalidated before `file_exists($versionFileName)` is called, to harden the updater for instances with `opcache.enable_file_override`.

Signed-off-by: MichaIng <micha@dietpi.com>
@MichaIng MichaIng force-pushed the fix/harden-for-enable_file_override branch from 0678abf to b75ce7e Compare April 4, 2026 13:29
Copy link
Copy Markdown
Member

@skjnldsv skjnldsv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no issues with this 👍

Copy link
Copy Markdown
Collaborator

@Altahrim Altahrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we already have this on server side 👍

@Altahrim Altahrim merged commit 856af67 into master Apr 7, 2026
21 checks passed
@Altahrim Altahrim deleted the fix/harden-for-enable_file_override branch April 7, 2026 12:41
@github-actions
Copy link
Copy Markdown

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Update step "moving files in place" failed due to missing version.php

3 participants