Page MenuHomePhabricator

DisplayTitle shows nothing when linking to an anchor on a page with the same display as its anchor
Closed, DuplicatePublicBUG REPORT

Description

The fix added for https://phabricator.wikimedia.org/T275984 is overly greedy in what it fixes; if you try to display [[Page#Section|Section]] with DisplayTitle enabled, no output shows up.

Similarly, [[Page#Section|ExtraTextHereSection]] has its text truncated to ExtraTextHer.

This is caused by the following block of code:

				if ( substr( $text, -$fragmentLength ) === $fragment ) {
					$textTitle = substr( $text, 0, -( $fragmentLength + 1 ) );
					$textFragment = $fragment;
				} else {
					$textTitle = $text;
					$textFragment = '';
				}

If we comment the first block and simply write:

					$textTitle = $text;
					$textFragment = '';

then the issue goes away, but I don't know what is needed to preserve the fix for https://phabricator.wikimedia.org/T275984.

(At worst I could gate this behind another setting, if it's impossible to fix this while retaining the SMW fix.)

Event Timeline

i agree. we face the same issue w/ our clients' wikis.

Oh @cicalese should I go ahead and do that last-resort patch?

Yes, I think so. I don't see any other way to definitively distinguish the SMW case.

@Xxmarijnw: In such cases, please feel free to Edit Related Tasks...Close As Duplicate in the upper right corner. Thanks!

Change 856547 had a related patch set uploaded (by WgevaertWikiBase; author: WgevaertWikiBase):

[mediawiki/extensions/DisplayTitle@REL1_35] Fix T305624 and T309051: Do not remove fragments if not proper part of text

https://gerrit.wikimedia.org/r/856547

Change 856547 had a related patch set uploaded (by Aklapper; author: WgevaertWikiBase):

[mediawiki/extensions/DisplayTitle@REL1_35] Do not remove fragments if not proper part of text

https://gerrit.wikimedia.org/r/856547

Change 856547 had a related patch set uploaded (by WgevaertWikiBase; author: WgevaertWikiBase):

[mediawiki/extensions/DisplayTitle@REL1_35] Fix T305624 and T309051: Do not remove fragments if not proper part of text

https://gerrit.wikimedia.org/r/856547

Change 856547 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: WgevaertWikiBase):

[mediawiki/extensions/DisplayTitle@REL1_35] Do not remove fragments if not proper part of text

https://gerrit.wikimedia.org/r/856547

Change 871136 had a related patch set uploaded (by WgevaertWikiBase; author: WgevaertWikiBase):

[mediawiki/extensions/DisplayTitle@master] Do not remove fragments if not proper part of text

https://gerrit.wikimedia.org/r/871136

Change 871136 merged by jenkins-bot:

[mediawiki/extensions/DisplayTitle@master] Do not remove fragments if not proper part of text

https://gerrit.wikimedia.org/r/871136

Change 856547 merged by jenkins-bot:

[mediawiki/extensions/DisplayTitle@REL1_35] Do not remove fragments if not proper part of text

https://gerrit.wikimedia.org/r/856547

Change 886419 had a related patch set uploaded (by Cicalese; author: WgevaertWikiBase):

[mediawiki/extensions/DisplayTitle@REL1_38] Do not remove fragments if not proper part of text

https://gerrit.wikimedia.org/r/886419

Change 886420 had a related patch set uploaded (by Cicalese; author: WgevaertWikiBase):

[mediawiki/extensions/DisplayTitle@REL1_39] Do not remove fragments if not proper part of text

https://gerrit.wikimedia.org/r/886420

Change 886419 merged by jenkins-bot:

[mediawiki/extensions/DisplayTitle@REL1_38] Do not remove fragments if not proper part of text

https://gerrit.wikimedia.org/r/886419

Change 886420 merged by jenkins-bot:

[mediawiki/extensions/DisplayTitle@REL1_39] Do not remove fragments if not proper part of text

https://gerrit.wikimedia.org/r/886420