Page MenuHomePhabricator

Fix the `url=` preset parameter to the UrlShortener at https://w.wiki
Closed, DeclinedPublic

Description

While this code:

		$localURL = SpecialPage::getTitleFor( 'UrlShortener' )->getLocalURL( [ 'url' => $fullURL ] );

works for the full URL:

It appears to not be working using the short domain:

Note that this will not produce a url directly, it merely presets the form so that users don't have to copy things from the address bar manually.

Event Timeline

Change 609216 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/UrlShortener@master] Make Special:UrlShortener read default URL from URL

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/UrlShortener/ /609216

The first one does not work., but the second does. Clicking https://meta.wikimedia.org/wiki/Special:UrlShortener?url=https://wikimedia.org/ shows the form populated with the url.

The first one does not work., but the second does. Clicking https://meta.wikimedia.org/wiki/Special:UrlShortener?url=https://wikimedia.org/ shows the form populated with the url.

Huh, interesting! I tried that several times and could not get it work. I see it working now though... Yay!

There is (currently unused code) in the extension that demonstrates how it would work:
$localURL = SpecialPage::getTitleFor( 'UrlShortener' )->getLocalURL( [ 'url' => $fullURL ] );

This code is still used in the extension. Its use will only be seen on wikis where the extension sidebar link is not disabled though. It creates the sidebar link that allows direct generation without going to the Special page. (The extension loads a js module that does that via the API). This is disabled on WMF wikis but it's enabled by default in the extension.

It's a bit tricky what's happening here, but I believe I understand it.

Change 614748 had a related patch set uploaded (by Ammarpad; owner: Ammarpad):
[mediawiki/extensions/UrlShortener@master] UrlShortener: Remove config renaming hack

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

Change 614748 had a related patch set uploaded (by Ammarpad; owner: Ammarpad):
[mediawiki/extensions/UrlShortener@master] UrlShortener: Remove config renaming hack

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

Wrong task number.

I assume this is in the config for the short domain somewhere, but is it even documented anywhere that this should work? Gadgets can just use the long URL or the API (example) at no cost to the user. In fact using the short URL would be slightly slower due to the redirect.

Legoktm added a subscriber: Legoktm.

This isn't an issue with the exception, rather the Varnish configuration for w.wiki strips all query parameters: https://gerrit.wikimedia.org/r/plugins/gitiles/operations/puppet/+/refs/heads/production/modules/varnish/templates/text-frontend.inc.vcl.erb#370 so people can't do stuff like https://w.wiki?search=foo

Allowing a query parameter of url= would be fine I guess, but I agree with @Esanders that there's not much utility in supporting this. Please re-open if you disagree.