Repository navigation
fix(files): reload mimetypes once per unknown id - #67681
Open
kukanggg89 wants to merge 1 commit into
Open
kukanggg89 wants to merge 1 commit into
kukanggg89 wants to merge 1 commit into
Conversation
Loader::getMimetypeById() and exists() only went back to the database while $loadedFromDatabase was false, and loadMimetypes() set that flag on the first database read. A long-running process never saw rows another process added later, so getMimetypeById() returned null and files of that type fell back to application/octet-stream. Track the ids and mimetypes that already triggered a reload and go back to the database once per unknown id or mimetype. A row added later is picked up on the next lookup, and a genuinely unknown id still costs at most one extra query. Signed-off-by: parel <farelalfarizi89@gmail.com> Assisted-by: Muse:Muse Spark 1.3
kukanggg89
requested review from
icewind1991 and
leftybournes
and removed request for
a team
December 4, 2026 07:34
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
getMimetypeById()returnsnullfor a mimetype added later (fulltextsearch:liveindexes such files without content) #67153Summary
Long-running processes only read oc_mimetypes from the database once. After the first database read, Loader kept serving its in-memory copy, so a mimetype another process added later stayed invisible: getMimetypeById() returned null and the file fell back to application/octet-stream. That is how a running occ fulltextsearch:live ended up indexing fresh .txt files with empty content on a new instance.
Loader now keeps track of the ids and mimetypes that already triggered a reload, and goes back to the database once per unknown id or mimetype. This follows the direction from the issue discussion. exists() gets the same treatment, since it had the same stale read and getId() relies on it. A row added later is picked up on the next lookup, and a genuinely unknown id still costs at most one extra query. reset() clears the tracking along with the loaded data.
Two tests cover it in tests/lib/Files/Type/LoaderTest.php, using the same loader instance throughout: one for a mimetype inserted directly in the database after the first lookup, one for exists() finding a mimetype added the same way.
I could not run the tests here (no PHP on this machine), so the repo CI has the final say.
TODO
Checklist
3. to review, feature component)stable32)AI (if applicable)
Drafted with help from Claude. I reviewed and revised every change myself before opening this PR.