Last modified: 2014-02-12 23:32:53 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T49292, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 47292 - ResourceLoader creates absolute URLs to load.php
ResourceLoader creates absolute URLs to load.php
Status: RESOLVED INVALID
Product: MediaWiki
Classification: Unclassified
ResourceLoader (Other open bugs)
1.20.x
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-04-16 20:03 UTC by Daniel Renfro
Modified: 2014-02-12 23:32 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Daniel Renfro 2013-04-16 20:03:24 UTC
The last line of ResourceLoader::makeLoaderURL() contains a call to wfAppendQuery() wrapped in a call to wfExpandUrl(). The effect is to create a URL to load.php that contains descriptions of resources -- which it does: a fully-qualified URL with the protocol. In most cases this works fine, but the protocol observed by the server is not guaranteed to be the same as the protocol submitted by the client because of various things like load-balancers, proxies, etc.

In our enterprise environment, SSL is terminated at the load-balancer. However, for Special:UserLogin we force HTTPS (to avoid security implications with clear-text passwords.) When Special:UserLogin loads, the HTML response is loaded over HTTPS, but it contains HTTP links to load.php -- which fail on some browsers which do not load mixed-protocol content. ( Chrome :/ )

Arguably this is a bug with wfExpandURL() and not the ResourceLoader, but this is where it manifested itself first. The solution which would preserve current behavior while enabling desirable behavior is a simple configuration variable: $wgForceRelativeUrls. When set to true, wfExpandURL() would just return its first parameter (the relative url.)

Possible duplicate of Bug 29969
Comment 1 Roan Kattouw 2013-04-16 20:07:29 UTC
The intent of makeLoaderURL() is to generate domain-relative URLs of the form /w/load.php?.... Looks like that broke at some point.
Comment 2 Daniel Renfro 2013-04-16 20:24:13 UTC
You're right Roan. 

Although the ResourceLoader emits fully-qualified URLs instead of domain-relative URLs, my opinion is that this should be done for all of MW. (There's probably some arcane reason why it isn't, and I just don't know about said reason.)
Comment 3 Krinkle 2013-04-17 11:49:10 UTC
At Wikimedia HTTPS is implemented through a cluster of NGINX nodes in front of the cluster that serves all HTTP requests (using Apache in our case).

Though this may change, the principle sounds similar to yours.

This is among the reasons we use protocol-relative urls so that the cache can be shared.

So for www.mediawiki.org and en.wikipedia.org for example:

$wgServer = '//www.mediawiki.org';

Also note that there is $wgCanonicalServer and $wgInternalServer which can come in handy.
Comment 4 Krinkle 2013-04-17 11:55:12 UTC
I left it out here (implied), but maybe I should make it explicit:

MediaWiki supports protocol-relative urls very well. It was a major thing in MediaWiki 1.18[1], which is around the time Wikimedia started using native HTTPS support on all domains.

In fact, the method you refer to (ResourceLoader::makeLoaderURL) explicitly orders wfExpandUrl to allow the url to be relative (instead of expanding to http:// or https:// ), by passing PROTO_RELATIVE.

PROTO_RELATIVE tells wfExpandUrl to keep the url relative if the MediaWiki configuration indicates that the server supports both, which you do by setting $wgServer to a protocol-relative url of the host name.

Otherwise, for things that need t be a full furl including protocol, $wgCanonicalServer is used (defaults to HTTP).

[1] https://www.mediawiki.org/wiki/MediaWiki_1.18
Comment 5 Daniel Renfro 2013-04-18 02:23:27 UTC
I guess I never knew that Mediawiki supported relative-URLs. After digging through  the WebRequest class and having a closer look at wfExpandURL() it seems obvious. I never realized you could set $wgServer, I just assumed it was always dynamically generated. 

In my case, since I only want to force HTTPS for a single page (Special:UserLogin,) my extension just does a str_replace() on $wgServer at the right time under the right conditions. I can see the usefulness in setting $wgServer to a relative URL in LocalSettings, however.

I've closed this as INVALID since it's not really a bug, and written a bit of documentation: http://www.mediawiki.org/w/index.php?title=Manual%3A%24wgServer&diff=674744&oldid=664348

Thanks Roan, Timo.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links