Page include feature allows content to have duplicate IDs #3461

Closed
opened 2026-02-05 06:47:13 +03:00 by OVERLORD · 2 comments
Owner

Originally created by @gaufde on GitHub (Jan 20, 2023).

Describe the Bug

I'm not exactly sure if this is best described as a bug or a feature request. However, when using the page include feature, it is possible to have ID's duplicated on the same page.

Steps to Reproduce

As an example, if you include an entire page twice, then all of the content IDs will be duplicated.

Obviously this example is a little weird since there is not good reason to include an entire page twice. However, if you start to make modifications as described in #3854, and you use page templates to create an outline for multiple pages, then it is easy for you to accidentally get duplicate IDs on one page that embeds similar content from multiple other pages.

Expected Behaviour

This likely won't be a high-priority bug to fix, but I think it should be considered as the page include feature grows.

I'm not exactly what the best way to fix this issue is. Maybe the content IDs should somehow be re-generated on the new page after the inserted content is parsed and included.

Alternatively, Bookstack could force IDs to be unique across all pages.

Screenshots or Additional Context

No response

Browser Details

No response

Exact BookStack Version

BookStack v22.11.1

PHP Version

No response

Hosting Environment

N/A

Originally created by @gaufde on GitHub (Jan 20, 2023). ### Describe the Bug I'm not exactly sure if this is best described as a bug or a feature request. However, when using the page include feature, it is possible to have ID's duplicated on the same page. ### Steps to Reproduce As an example, if you include an entire page twice, then all of the content IDs will be duplicated. Obviously this example is a little weird since there is not good reason to include an entire page twice. However, if you start to make modifications as described in #3854, and you use page templates to create an outline for multiple pages, then it is easy for you to accidentally get duplicate IDs on one page that embeds similar content from multiple other pages. ### Expected Behaviour This likely won't be a high-priority bug to fix, but I think it should be considered as the page include feature grows. I'm not exactly what the best way to fix this issue is. Maybe the content IDs should somehow be re-generated on the new page after the inserted content is parsed and included. Alternatively, Bookstack could force IDs to be unique across all pages. ### Screenshots or Additional Context _No response_ ### Browser Details _No response_ ### Exact BookStack Version BookStack v22.11.1 ### PHP Version _No response_ ### Hosting Environment N/A
OVERLORD added the 🐛 Bug label 2026-02-05 06:47:13 +03:00
Author
Owner

@gaufde commented on GitHub (Jan 23, 2023):

I have just thought of a much easier way to fix this issue. When content is being embedded, the content ID of each child element should be combined with the content ID of the parent.

So, Bookstack could get the content ID of the node that contains the include tag and append/prepend it to the contend IDs of all the nodes that get embedded.

This should prevent duplicate content IDs even if the same content is embedded into a page twice. The only time where this solution would fail is if content with the same ID is embedded more than once in the same parent node. However, I don't see any useful reason why someone would need to do that, and so it doesn't seem like an edge case to worry much about.

@gaufde commented on GitHub (Jan 23, 2023): I have just thought of a much easier way to fix this issue. When content is being embedded, the content ID of each child element should be combined with the content ID of the parent. So, Bookstack could get the content ID of the node that contains the include tag and append/prepend it to the contend IDs of all the nodes that get embedded. This should prevent duplicate content IDs even if the same content is embedded into a page twice. The only time where this solution would fail is if content with the same ID is embedded more than once in the same parent node. However, I don't see any useful reason why someone would need to do that, and so it doesn't seem like an edge case to worry much about.
Author
Owner

@ssddanbrown commented on GitHub (Nov 28, 2023):

Thanks for reporting @gaufde.
I've just made some significant changes to page includes within #4688, for which it should not consider duplicate IDs and alter them as required. These changes will be part of the next feature release, so I'll therefore close this off.

@ssddanbrown commented on GitHub (Nov 28, 2023): Thanks for reporting @gaufde. I've just made some significant changes to page includes within #4688, for which it should not consider duplicate IDs and alter them as required. These changes will be part of the next feature release, so I'll therefore close this off.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#3461