Page MenuHomePhabricator

External Link icons not shown on MediaWiki 1.36.0
Closed, ResolvedPublic

Description

I found that since my site upgraded to 1.36.0, all the external links are no longer with a external link icon beside them. Then I opened my devtools and found this:

image.png (125×384 px, 8 KB)

A double slash instead of the expected single slash is in the url. I doubted with my local settings so I posted on the MediaWiki Discord but it seems fine:
image.png (261×582 px, 24 KB)

Please notice that my $wgScriptPath is "". I found wmf hosted wikis are fine but their script path is with "w/".
Only external link icons, as well as ftp mailto etc. icons, are affected. Other images under resource is fine, e.g. the Powered by MediaWiki icon, the license icon.
For skins that overrides the links icon written in mediawiki.skinning.content.externallinks (e.g. Vector), the icons are still there. So probably it's not related to a single skin.

Event Timeline

Reproducible for me as well. Similar to T282280 but that patch doesn't cause nor fixes it (I've tried reversing it with no changes)

It may be related to: rMWe2a91921c5bd951873a524ed9c085408881d4363

Krinkle triaged this task as High priority.Jun 7 2021, 6:39 PM

On a non-root wiki, steps to reproduce:

  1. Find equivalent of http://default.web.mw.localhost:8080/mediawiki/load.php?lang=en&modules=skins.vector.styles.legacy&only=styles&skin=vector&debug=true and open it.
  2. Set $wgScriptPath = ""; in LocalSettings.php.
  3. Refresh.

The resulting output contains:

/* Good */
  background-image: url(/skins/Vector/resources/common/images/user-avatar.svg?b7f58);
/* Good */
  .mw-wiki-logo { background-image: url(/resources/assets/wiki.png?4d48b); }
/* Bad */
  background-image: url(//resources/src/mediawiki.skinning/images/magnify-clip-ltr.png?4f704);

In SkinModule::getStyleFiles, the FilePath values are as follows:

"screen": [
    {
        "filepath": "resources/src/mediawiki.skinning/content.thumbnails.less",
        "local": "/var/www/mediawiki",
        "remote": "/"
    },

That seems okay. The remote here is set as $defaultRemoteBasePath which comes from ResourceLoaderFileModule::extractBasePaths( .., ResourceBasePath) which correctly turns '' into '/'.

Later on, in FileModule::processStyle() when it is time to call CSSMin for remapping, we observe that the input has already been damanged by this point:

{
    "$localPath": "/var/www/mediawiki/resources/src/mediawiki.skinning/content.thumbnails.less",
    "$remotePath": "//resources/src/mediawiki.skinning/content.thumbnails.less"
}
{
    "$localDir": "/var/www/mediawiki/resources/src/mediawiki.skinning",
    "$remoteDir": "//resources/src/mediawiki.skinning"
}

Backing up from there, we see it works fine for skin and extension file paths:

ResourceLoaderFileModule::getRemotePath: $path arg = <string> = resources/common/common.less
{
    "$localPath": "/var/www/mediawiki/skins/Vector/resources/common/common.less",
    "$remotePath": "/skins/Vector/resources/common/common.less"
}
{
    "$localDir": "/var/www/mediawiki/skins/Vector/resources/common",
    "$remoteDir": "/skins/Vector/resources/common"
}

But goes wrong for core paths from SkinModule:

ResourceLoaderFileModule::getRemotePath: $path arg = <ResourceLoaderFilePath>remotePath = //resources/src/mediawiki.skinning/content.thumbnails.less
{
    "$localPath": "/var/www/mediawiki/resources/src/mediawiki.skinning/content.thumbnails.less",
    "$remotePath": "//resources/src/mediawiki.skinning/content.thumbnails.less"
}
{
    "$localDir": "/var/www/mediawiki/resources/src/mediawiki.skinning",
    "$remoteDir": "//resources/src/mediawiki.skinning"
}

The problem seems to be that FilePath::getRemotePath() inserts a slash if the remote base is a non-empty string, which is expected to not have a trailing slash. And this expectation is violated by SkinModule which passes it the already processed value from extractBasePaths() where such root paths are no longer empty strings.

Change 698892 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/core@master] resourceloader: Fix remote bash path at document root passed into SkinModule

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

Change 698892 merged by jenkins-bot:

[mediawiki/core@master] resourceloader: Fix remote bash path at document root passed into SkinModule

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

Thanks! I've tested the patch on 1.36 and indeed fixes the problem

Change 699010 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/core@REL1_36] resourceloader: Fix remote bash path at document root passed into SkinModule

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

Change 699010 merged by jenkins-bot:

[mediawiki/core@REL1_36] resourceloader: Fix remote base path at document root passed into SkinModule

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