タイトルを URL から削除するとリンクが壊れる

All three of the following links are to the second post in this topic. However, only the first two work. The third one worked until very recently, and we use it pretty extensively in our community to avoid cluttering wiki posts that reference several posts within the topic. That third link now just loads endlessly and never actually shows the content.

[full title link](https://meta.discourse.org/t/link-to-post-within-same-topic-doesnt-work-if-there-is-no-title-in-the-url/121455/2)
full title link

[short title link](https://meta.discourse.org/t/short/121455/2)
short title link

[no title link](https://meta.discourse.org/t/121455/2)
no title link


P.S. Sorry about not using try.discourse.com earlier. I’ll create an account over there for next time.

Second post to demonstrate the bug.

What you’re actually using there is a hack, especially if it is a deep link to a specific post. This is the correct permalink URL form

https://meta.discourse.org/t/{title}/{topic-id}/{post-id}

This has been hacked up to work, when people accidentally omit the topic ID, we guess that if the “topic title” is all numeric, they meant the topic ID:

https://meta.discourse.org/t/{topic-id}

So this works

https://meta.discourse.org/t/121455

but this cannot, for what I hope are obvious reasons

https://meta.discourse.org/t/topic-title

But adding the post number to that is riskier.

I recommend not relying on sort of hacky undocumented behaviors, though, and switching to this formally supported form

https://meta.discourse.org/t/x/121455/2

The third link does work if you open it in a new tab. It’s only when you click within one tab that it breaks. And it breaks bad - you can’t even click the logo to go back to the front page of the forum.

TypeError: Cannot read property 'get' of undefined
    at n.setupController (application-779d3dc401b01d1322f0bf8b26cb0e5f4c83a62f26cbecbd52159a94370dffc3.br.js:68)
    at n.a.setup (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:8)
    at i (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17)
    at u.n.routeEnteredOrUpdated (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17)
    at u.n.setupContexts (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17)
    at u.n.finalizeTransition (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17)
    at ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17
    at f (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17)
    at T (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17)
    at E (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17)

Error while processing route: topic.fromParams Cannot read property 'get' of undefined TypeError: Cannot read property 'get' of undefined
    at n.setupController (https://d11a6trkgmumsb.cloudfront.net/assets/application-779d3dc401b01d1322f0bf8b26cb0e5f4c83a62f26cbecbd52159a94370dffc3.br.js:68:14673)
    at n.a.setup (https://d11a6trkgmumsb.cloudfront.net/assets/ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:8:6889)
    at i (https://d11a6trkgmumsb.cloudfront.net/assets/ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17:23930)
    at u.n.routeEnteredOrUpdated (https://d11a6trkgmumsb.cloudfront.net/assets/ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17:24069)
    at u.n.setupContexts (https://d11a6trkgmumsb.cloudfront.net/assets/ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17:23260)
    at u.n.finalizeTransition (https://d11a6trkgmumsb.cloudfront.net/assets/ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17:22253)
    at https://d11a6trkgmumsb.cloudfront.net/assets/ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17:21378
    at f (https://d11a6trkgmumsb.cloudfront.net/assets/ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17:29538)
    at T (https://d11a6trkgmumsb.cloudfront.net/assets/ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17:30915)
    at E (https://d11a6trkgmumsb.cloudfront.net/assets/ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17:30814)

Uncaught TypeError: Cannot read property 'cancelFilter' of undefined
    at n.deactivate (application-779d3dc401b01d1322f0bf8b26cb0e5f4c83a62f26cbecbd52159a94370dffc3.br.js:68)
    at n [as deactivate] (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:10)
    at n.a.exit (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:8)
    at u.n.setupContexts (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17)
    at u.n.getTransitionByIntent (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17)
    at u.n.transitionByIntent (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17)
    at u.n.doTransition (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17)
    at u.n.intermediateTransitionTo (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17)
    at n.s.intermediateTransitionTo (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:8)
    at n.a.intermediateTransitionTo (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:8)

Yep, it’s being treated like a permalink redirect and they’re not supported for internal links.

Unfortunately we had no way of knowing that this wasn’t officially supported behavior. As far as we were concerned, it worked. So we used it. I’ll try to let people know not to use that approach from now on, but unfortunately that doesn’t help us now when we have hundreds of these floating around.

As @Dannii said, it only breaks when it’s clicked to load in the same tab, and pretty badly. Even if it’s only really supported for when people do this by accident, doesn’t that still mean it should be fixed? Especially since it works when the topic is different.

投稿から正規表現に一致する URL を検索できます。私の知る限り、タイトル欄に何かを入力するだけでよく、実際のタイトルである必要はありませんが、何らかの入力が必要です。

タイトルには何を指定しても構いません。ただし、私の投稿を見つけるほど簡単ではありません。一部のコミュニティでは、冗長な URL を避けるためにタイトルを完全に削除する慣習が一般的になっています。そのため、複数のユーザーがすべてのリンクを修正する必要があります。

なぜこれがサポートに移されたのでしょうか?ページが無限に読み込まれ続けるのは明らかなバグです。修正によってタイトルなしの URL が再び機能するようにならないとしても、です。また、場合によっては機能する(別の投稿へのリンクやアドレスバーへの直接 URL 入力など)のに、このケースでは機能しないのは、私の意見では理にかなっていません。

意図しない使用により修正が必要となったため、これは最初からサポート対象外のものでした。バグとは機能上の不具合を指しますが、今回のケースは該当しません。

また、タイトルがなければリンクは作成されないという事実を反映するため、件名も更新しました。今回の問題は、手動でリンクを入力したか、リンクのタイトルが削除されたことに起因しています。Discourse が問題の根源であるとは決して言えず、したがって Discourse のバグでもありません。

データベースを確認すれば、すべての壊れたリンクを一度に特定できます。ユーザーが手動で修正し直す必要はありませんが、今後同様のことが起こらないよう、ユーザーに対する再教育は必須です。

私は管理者ではないため、残念ながらそれはできません。

それでも、ページが無限に読み込み続けることが許容されるのでしょうか?404 ページにリダイレクトするだけでも、その方がまだマシです。

でも、それではあなたの問題は解決しないですよね?

長期的には、彼らはリンクを修正する必要があります。なぜなら、彼らが行っていたことは基本的にサポートされていないハックだったからです。

私が言ったように、トピック ID のみは公式にサポートされている形式です(「タイトルを忘れた」というケースをカバーするため)。しかし、トピック ID にポスト ID を追加した形式はサポートされていません。

@eviltrout さん、どのような動作にすべきかご意見をお聞かせください(最初の投稿の 3 番目のリンクを参照)。

おっと、それは興味深いですね。なぜ両者を区別して扱うのでしょうか?タイトルを忘れることはあっても、特定の投稿に関心を持つケースはないのでしょうか?

これはかなり厄介なハックで、テキストを数値として扱っているためです。本質的には、「ユーザーがかなり混乱しているようだ、できる限りのことをしよう」という非常用出口です。これは人々が依存すべき主要なナビゲーション手段として意図されたものではなく、特に投稿IDも絡んでくる場合はそうです。

検出はリンククリック時のみ行われているのでしょうか?投稿が生成された時点で検出し、問題のあるリンクにクラスを適用することはできませんか?

これがコミュニティにとってそれほど重要な問題なら、なぜ管理者がここで議論しないのでしょうか?最終的に修正を適用するのは彼らです。

サーバー側でそのケースを処理しているのは興味深いですね。/t/:topic_id/:post_number という特定のルートが存在します。

一致するのは topic_idpost_number が数値の場合のみです。その場合、正しいトピックのスラッグを検索してそこにリダイレクトします。

サーバー側でサポートされている以上、クライアント側でもサポートすべきだと考えます。正しいスラッグを AJAX で lookup して表示できるのに、エラーページを表示するのは理にかなっていません。とはいえ、そのようなリンクの使用は推奨しません。その追加の lookup は、ほとんど意味のない理由による余計な Web リクエストになるからです。

たまたま気づいたので、取り上げました。このコミュニティは非常に放任主義なので、本当に重要な場合に限って管理者を巻き込むようにしています。私はコミュニティで非常に活発で、特にこの変更の影響を最も受けるサブグループで活動しています。

ハック的、意図的ではない、あるいは何でも構いませんが、このバグは修正する必要があると思います。これが露呈した今、トロールが意図的にこれらのリンクを作成する可能性があります。トピックが読み込まれないだけでなく、サイト全体が破損することを覚えておいてください。

こちらで、私の新しいゲームをチェックしてください!

厳密にはそうではありません。バックボタンを押すことができますから。

このタスクを誰かに割り当てたいですか?@eviltrout

私の環境では動作しません…

不適切なリンクをクリックした後、以下の操作がすべて機能しなくなります。

  • ブラウザの戻るボタンをクリック
  • ロゴをクリック
  • トピックタイトルをクリック
  • 検索
  • ハンバーガーメニューから「最新/未読/タグ」などをクリック

私が確認したところ、通知をクリックするか、ページをリフレッシュする以外に動作する方法はありませんでした。