Skip to content

fix(db): an edit deletes the empty page it no longer references - #13675

Closed
yuxi-liu-wired wants to merge 2 commits into
logseq:masterfrom
yuxi-liu-wired:fix/orphaned-page-on-edit
Closed

yuxi-liu-wired wants to merge 2 commits into
logseq:masterfrom
yuxi-liu-wired:fix/orphaned-page-on-edit

Conversation

@yuxi-liu-wired

@yuxi-liu-wired yuxi-liu-wired commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Typing [[Brand new]] in a block creates the page "Brand new". Deleting that reference from the block again is meant to delete the page when it is empty and nothing else references it: save-block calls remove-orphaned-page-refs! for that. It never deletes anything.

ldb/get-orphaned-pages keeps a page that has (:block/properties page). In a DB graph, :block/properties (entity-plus/get-properties) lists every property attribute of the entity, and :block/tags is one: every page has the Page (or Journal) tag, so every page has properties and none ever qualifies.

The fix: only properties other than :block/tags keep a page.

Test: src/test/logseq/outliner/orphaned_pages_test.cljs. An edit from [[Kept]] [[Dropped]] to [[Kept]] deletes the empty page Dropped and keeps Kept (fails on master: Dropped stays); a page with a property (a checkbox set on it) is kept; a save without a title (collapsing the block) keeps the pages the block references, since the cleanup runs only when the title changes. The test is in the app's test build because the outliner library's nbb run does not compute :block/properties. The editor, undo/redo, page, outliner, pipeline and DB core test namespaces pass with the change.

yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 11, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 13, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 16, 2026
Typing [[Brand new]] in a block creates the page Brand new; deleting the reference from the block again is meant to delete that page when it is empty and nothing else references it (remove-orphaned-page-refs! on save). It never did: get-orphaned-pages keeps a page with (:block/properties page), and in a DB graph every page's :block/properties holds its :block/tags (the Page or Journal tag), so no page ever qualified. Only properties other than :block/tags keep a page now.
With the cleanup working, a save that does not change the title (collapsing a block) must not take the block's pages for orphans: the cleanup runs only when the title changes.
@yuxi-liu-wired

Copy link
Copy Markdown
Contributor Author

Combined with the other PRs that change the same files into #13786.

@yuxi-liu-wired
yuxi-liu-wired deleted the fix/orphaned-page-on-edit branch October 21, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant