Uh oh!
There was an error while loading. Please reload this page.
fix(ContentManager): look up existing row before insertOrUpdate - #262
Open
oboeglen wants to merge 1 commit into
Open
fix(ContentManager): look up existing row before insertOrUpdate#262oboeglen wants to merge 1 commit into
oboeglen wants to merge 1 commit into
Conversation
kyteinsky
requested changes
Aug 10, 2026
kyteinsky
left a comment
Contributor
There was a problem hiding this comment.
thanks for the fix!
I had assumed it would auto-fallback on update when unique constrain fails but well it seems each db has its own way of doing that so your solution seems like the best approach here even with the two query calls instead of one.
Uh oh!
There was an error while loading. Please reload this page.
kyteinsky
commented
Aug 10, 2026
Contributor
A few other minor details:
|
insertOrUpdate() can only fall back to update() correctly when the entity's id is already known ahead of time. submitContent() always built a fresh QueueContentItem (no id), so re-submitting content that was already indexed (unique constraint on app_id/provider_id/item_id) threw InvalidArgumentException: Entity which should be updated has no id, and the update silently never happened (caught and logged). Look up the existing row by its unique key first and reuse its id when present, calling insert()/update() explicitly instead of relying on insertOrUpdate()'s exception-driven fallback. Fixesnextcloud#261 Signed-off-by: Olivier <oboeglen@users.noreply.github.com>
oboeglenforce-pushed
the
fix/insertOrUpdate-missing-id
branch
from
August 14, 2026 08:44
a038031 to
5196d43Compare
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 freeto 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.
Fixes#261.
ContentManager::submitContent()always built a freshQueueContentItementity (no id) and called$this->mapper->insertOrUpdate($dbItem).QBMapper::insertOrUpdate()can only fall back toupdate()correctly when the entity's id is already known ahead of time — here it never is, so re-submitting content that was already indexed (unique constraint onapp_id/provider_id/item_id) threw:caught and logged by the existing
catch (Exception $e), meaning the update silently never happened.This PR looks up the existing row by its unique key first (new
QueueContentItemMapper::findByUniqueKey()) and reuses its id when found, callinginsert()/update()explicitly instead of relying oninsertOrUpdate()'s exception-driven fallback with a freshly-constructed entity.Reproduced with the
bookmarksapp re-crawling and re-submitting an already-indexed bookmark (full trace in #261), but the bug is generic to any provider re-submitting previously-indexed content.