Page MenuHomePhabricator

DisplayTitle shows nothing when linking to an anchor on a page with the same display as its anchor
Open, Needs TriagePublicBUG 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.