fix(versions): preserve version encrypted version before rollback - #61562
fix(versions): preserve version encrypted version before rollback#61562leftybournes wants to merge 1 commit into
Conversation
Signed-off-by: Kent Delante <kent@delante.me>
| $versionCache->update( | ||
| $versionFileInfo->getId(), [ | ||
| 'encrypted' => $encryptedVersion, | ||
| 'encryptedVersion' => $encryptedVersion, |
There was a problem hiding this comment.
encrypted should probably not get set or at least not to the version?
There was a problem hiding this comment.
When I tested it, just setting encryptedVersion "corrupts" the version but also setting encrypted fixes the issue.
There was a problem hiding this comment.
I guess we already do some of this below too, but I feel like we should be letting the Encryption storage wrapper deal with these matters -- e.g.
server/lib/private/Files/Storage/Wrapper/Encryption.php
Lines 644 to 654 in 2da90a9
There was a problem hiding this comment.
@joshtrichards I dug into it further and it seems it's already handled in the Encryption wrapper.
server/lib/private/Files/Storage/Wrapper/Encryption.php
Lines 631 to 637 in 2da90a9
The problem is the encryptedVersion value gets overwritten when a new version is created. I noticed a sequence where Encryption sets the encryptedVersion and then View calls a copyUpdate which overwrites the encryptedVersion value to 1 which is why this workaround is needed.
server/lib/private/Files/View.php
Lines 1000 to 1002 in 2da90a9
joshtrichards
left a comment
There was a problem hiding this comment.
This is begging for test coverage. :-)
|
After doing some further digging, I found the root cause and opened a new pull request. I'll close this if it's merged. |
|
Closing this in favor of #62255 |
Summary
While rolling back, the created file version's encrypted version is set to 1 when it is actually higher, causing it to appear corrupted when restoring to it. This preserves the encrypted version for the created file version to prevent "corruption" from happening.
Checklist
3. to review, feature component)stable32)AI (if applicable)