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

[BUGFIX] Use the document cache in getDocumentByUid() #1405

Merged
merged 4 commits into from
Dec 18, 2024

Conversation

michaelkubina
Copy link
Collaborator

Several controllers rely on the retrieval of the document via loadDocument(). The function getDocumentByUid() in the AbstractController.php calls AbstractDocument::getInstance() with the $forceReload parameter being true. With this we never get the actually cached document, but instead force loading the METS-File every time.

I have tracked execution time and the change dropped the 400ms for loadDocument() to about 80ms on a typical document with several hundred pages. Since we use multiple controllers in a details page (pageview, navigation, etc.) this adds up pretty fast.

I believe this is just an oversight, or is there a good reason why this parameter was set to true?

@sebastian-meyer sebastian-meyer added the 🐛 bug A non-security related bug. label Dec 16, 2024
@sebastian-meyer sebastian-meyer changed the title [MAINTENANCE] Use the document cache in getDocumentByUid() [BUGFIX] Use the document cache in getDocumentByUid() Dec 16, 2024
Copy link
Member

@sebastian-meyer sebastian-meyer left a comment

Choose a reason for hiding this comment

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

This seems fine. I think forcing the reload here is a bug.

@beatrycze-volk Do you know of a good reason why we would do that?

@sebastian-meyer sebastian-meyer changed the title [BUGFIX] Use the document cache in getDocumentByUid() [BUGFIX] Use the document cache in getDocumentByUid() Dec 17, 2024
@beatrycze-volk
Copy link
Collaborator

This seems fine. I think forcing the reload here is a bug.

@beatrycze-volk Do you know of a good reason why we would do that?

This change is fine. I don#t know why it is like that now, but it should be changed as @michaelkubina proposed.

@sebastian-meyer sebastian-meyer merged commit 89c4dd9 into kitodo:main Dec 18, 2024
8 checks passed
Copy link

codecov bot commented Dec 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (2ac3a96) to head (eae6acc).
Report is 1 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff      @@
##   main   #1405   +/-   ##
============================
============================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug A non-security related bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants