Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(files): Don't attempt to format a partial cache entry #43131

Conversation

ChristophWurst
Copy link
Member

@ChristophWurst ChristophWurst commented Jan 25, 2024

Summary

\OC\Files\Cache\Wrapper\CacheWrapper::get should return \OCP\Files\Cache\ICacheEntry but home cache sometimes returns partial cache entries that are plain arrays. If they are processed in \OC\Files\Cache\Wrapper\CacheWrapper::formatCacheEntry and overrides, information might be missing. This happens in \OCA\Files_Sharing\Cache::formatCacheEntry when there is no path and \OC\Files\Cache\Wrapper\CacheJail::getJailedPath returns null. Using null for the path passed to \OCA\Files_Sharing\SharedStorage::getPermissions eventually leads to nextcloud/files_accesscontrol#464.

So the theory and the tale. This is my first time touching cache wrappers. Double and tripple check what I'm doing 🙏

TODO

  • Do

How to test

  1. Enable server side encryption
  2. Enable terms of service
  3. Create user1
  4. Create user2
  5. Create directory "S1" as user1, share with user2 r+w
  6. Log in as user2
    7.) Copy a file into S1 (due to [Bug]: Move or copy files and folders fails #42469 you might need cadaver)

Checklist

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
@@ -91,7 +91,7 @@ protected function formatCacheEntry($entry) {
*/
Copy link
Contributor

@come-nc come-nc Jan 29, 2024

Choose a reason for hiding this comment

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

The @return here is still wrong 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. I could return false if $result is in array. But not sure if this fixes bugs or creates more …

Copy link
Member Author

Choose a reason for hiding this comment

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

To do or not to do?

Copy link
Contributor

Choose a reason for hiding this comment

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

🤷 Not if you have no idea of the consequences. But at some point this return stack needs to be cleaned up and return the correct types.

Copy link
Member Author

Choose a reason for hiding this comment

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

Then I would prefer to leave it

@icewind1991
Copy link
Member

partial cache entries are the legacy gift that keep on giving and should really be removed

@ChristophWurst
Copy link
Member Author

/backport to stable28

@ChristophWurst
Copy link
Member Author

/backport to stable27

@ChristophWurst
Copy link
Member Author

/backport to stable26

Copy link
Contributor

@come-nc come-nc left a comment

Choose a reason for hiding this comment

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

To be continued…

@ChristophWurst ChristophWurst merged commit 67a3ab4 into master Feb 6, 2024
53 checks passed
@ChristophWurst ChristophWurst deleted the fix/files/cache-wrapper-no-partial-cache-entry-formatting branch February 6, 2024 12:51
@blizzz blizzz mentioned this pull request Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants