# ?page= 버그, 코어와 사이트맵 플러그인 모두에서 발생

**URL:** https://meta.discourse.org/t/page-bug-both-in-core-and-in-sitemap-plugin/191719
**Category:** Bug
**Tags:** sitemap
**Created:** [5월 26, 2021, 5:08오후 UTC](https://meta.discourse.org/t/page-bug-both-in-core-and-in-sitemap-plugin/191719 "2021-05-26T17:08:01Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [5월 26, 2021, 5:08오후 UTC](https://meta.discourse.org/t/page-bug-both-in-core-and-in-sitemap-plugin/191719/1 "2021-05-26T17:08:01Z")

</div>

여기에는 두세 개의 오프바이원(off-by-one) 오류가 겹쳐 있는 것 같습니다…

토픽에 게시물이 18개가 되는 순간, `sitemap_recent.xml`에 페이지 번호가 포함된 URL(`https://forum.example.com/t/slug/123?page=2`)이 표시되기 시작합니다.

문제 1: 게시물이 20개가 될 때까지 2페이지는 존재하지 않지만, 사이트맵에는 해당 링크가 표시됩니다.  
기대 동작: 토픽에 게시물이 20개가 될 때까지 사이트맵에 page=2 링크가 표시되지 않아야 합니다.

문제 2: 게시물이 18개인 경우, 해당 링크를 클릭하면 "해당 페이지가 존재하지 않습니다"라는 오류가 발생합니다.  
기대 동작: 이를 적절히 처리하여 사용자가 토픽의 마지막 페이지로 리다이렉트되어야 합니다.

문제 3: 게시물이 19개인 경우, 해당 링크를 클릭하면 "오류. 로드 중. 문제가 발생했습니다"라는 메시지가 표시됩니다.  
기대 동작: 이를 적절히 처리하여 사용자가 토픽의 마지막 페이지로 리다이렉트되어야 합니다.

문제 4: 게시물이 20개 이상이지만 게시물이 삭제되어 표시 가능한 게시물의 총 수가 줄어든 경우, 새 게시물이 하나 작성될 때까지 `?page=2`가 최근 사이트맵에 남아있고, 작성된 후에는 사라집니다.  
기대 동작: 페이지 번호가 사라지거나(또는 더 높은 페이지의 경우: 감소하여) 실제 사용 가능한 페이지 수를 반영해야 합니다.

더 나쁜 점: 이 잘못된 링크가 구글에도 표시되고 있습니다!  
문제 5: 해당 링크를 클릭하면 사용자에게 오류가 발생합니다.  
하지만 구글에서는 중복 콘텐츠가 생성되고 있는 것으로 보입니다.

메타(Meta)에서의 재현 방법:

1. 답글이 17개 또는 18개인 토픽을 찾습니다:  
 ![image](https://cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/optimized/3X/f/6/f68a92981873cb5fe9a80a6785349b0db973b0ba_2_690x45.png)

2. `https://meta.discourse.org/sitemap_recent.xml`에서 해당 토픽을 찾습니다.  

3. 링크를 따라갑니다.  

4. 구글에서 확인합니다.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [5월 26, 2021, 5:27오후 UTC](https://meta.discourse.org/t/page-bug-both-in-core-and-in-sitemap-plugin/191719/2 "2021-05-26T17:27:49Z")

</div>

음, 이건 안 좋네요! @zogstrip 님, 이걸 수정하고 백포트해야 합니다.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [5월 26, 2021, 9:53오후 UTC](https://meta.discourse.org/t/page-bug-both-in-core-and-in-sitemap-plugin/191719/3 "2021-05-26T21:53:37Z")

</div>

@nbianca 이것을 목록에 추가해 줄 수 있나요?

---

<div class="post-metadata">

### Author: ![nbianca](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nbianca/32/157984_2.png) [@nbianca](https://meta.discourse.org/u/nbianca)
#### Post date: [5월 27, 2021, 12:28오후 UTC](https://meta.discourse.org/t/page-bug-both-in-core-and-in-sitemap-plugin/191719/4 "2021-05-27T12:28:41Z")

</div>

페이지 번호를 계산하는 데 큰 문제는 discourse-sitemap에서 발생했습니다:

> <https://github.com/discourse/discourse-sitemap/pull/19>
>
> There were multiple off-by-one errors which counted as two pages of 20
> posts ev…en when there were only 19 posts.

캐싱 관련 문제는 여기서 수정되었습니다:

> <https://github.com/discourse/discourse-sitemap/pull/20>
>
> Using bumped\_at does not work as expected because deleting posts does
> not updat…e it.

또한 코어(core)의 not found 문제를(경미하게) 수정했습니다. 20개의 게시글(1페이지)만 존재하는 상태에서 두 번째 페이지를 요청할 때 200을 반환하던 문제였습니다:

> <https://github.com/discourse/discourse/pull/13183>
>
> The not found condition did not work for topics with chunk\_size posts,
> because …it considered it has two pages, but it only has one.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [6월 1, 2021, 12:57오후 UTC](https://meta.discourse.org/t/page-bug-both-in-core-and-in-sitemap-plugin/191719/5 "2021-06-01T12:57:46Z")

</div>


