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: Stale children block's path-refs when parent's refs change #9254
Conversation
(let [entity (db/entity [:block/uuid id])] | ||
{:db/id (:db/id entity) | ||
:block/path-refs (concat | ||
(map :db/id (:block/path-refs entity)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bug was here as :block/path-refs had stale data
@@ -41,14 +41,36 @@ | |||
[(:db/id (:block/page block))] | |||
(map :db/id (:block/refs block)) | |||
parents-refs)) | |||
;; Usually has changed as new-refs has page id while old-refs doesn't | |||
refs-changed? (not= old-refs new-refs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if it's intentional but this was always changed when I inspected it because the old-refs didn't contain the page id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bug because :block/path-refs
is included in the retracted-attributes, the block
here is from the db-after
which has no path-refs already. I made the change to get the old-refs from db-before
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QAed both and this fix works great! 👍
@@ -0,0 +1,54 @@ | |||
(ns frontend.modules.outliner.pipeline-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
a63d4e4
to
7c4ed4d
Compare
Also fix typo on 5677be9 /cc @tiensonqin
Looks like refs-changed? always being true in #9254 was needed for downstream transactions. This brings back that behavior
Looks like refs-changed? always being true in #9254 was needed for downstream transactions. This brings back that behavior
This fixes a longstanding bug where a child block's :block/path-refs holds on to old path-refs when a parent's refs change. Fixes #5759, #5992, #6990, #8430 and #4116. Since this bug allowed stale refs data, this lead to stale data in query results, linked references and maybe other places. To QA, add these blocks:
Observe that changing
#foo
to#bar
cleanly removes all the blocks from the query results. Another case to QA is toggle task states with children blocks as described in #5992