Skip to content

Renaming a page to a case variant of another page's name makes 2 pages with 1 name #1344

Closed
logseq/logseq
#13516

Description

@yuxi-liu-wired

Steps

  1. Press Cmd+K (Ctrl+K), type "Foo", and create the page.
  2. Create a second page the same way, "Bar".
  3. On the page "Bar", click the title, change it to "foo", and press Escape.

Expected

The rename is refused with "Another page named "foo" already exists", the way creating "foo" does not make a second page: Cmd+K with "foo" opens "Foo".

Actual

The rename goes through. The graph has 2 ordinary pages whose name is "foo" ("Foo" and "foo"), both at the top level. Typing [[foo]] in a block links to the older one, "Foo", not to the page titled "foo": a typed link finds its page by name and takes the oldest (resolve-page-ref, ldb/get-page, get-first-page-by-name).

The same happens for any case variant ("FOO", "fOo").

Cause

Page creation finds pages by :block/name, the title lower-cased by page-name-sanity-lc: the renderer's <create! pulls [:block/name ...] and opens the page it finds (src/main/frontend/handler/common/page.cljs:139-147), and the worker's create asks ldb/page-exists?, which matches :block/name for pages (deps/db/src/logseq/db.cljs:516-546).

A rename saves the title block, and save-block checks it with validate-block-title, then validate-unique-for-page (deps/outliner/src/logseq/outliner/validate.cljs:49-123), whose queries match [?b :block/title ?title]: the exact title. "foo" differs from "Foo", so the check passes.

Related: db-test#991 (several pages with the same name, reached by pasting) and db-test#718 (a graph holding both "obsidian" and "Obsidian").

Found by the page model property test (frontend.worker.page-model-property-test, branch test/page-model-fuzz) on upstream master 16c4ed1a0, through 2 of its checks: no 2 live ordinary pages share a name under the same parent (the rule <create! and page-exists? apply), and "create X" and "rename Y to X" are accepted alike. Shortest sequence: FUZZ_REPLAY='[[:create 0 0 0] [:rename 0 1 0]]' (create "Foo", rename the other page to "foo").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions