Page MenuHomePhabricator

Page banner not compatible with $wgUseInstantCommons = true;
Closed, ResolvedPublic

Description

When I enable [[ https://www.mediawiki.org/wiki/Manual:$wgUseInstantCommons | $wgUseInstantCommons ]]
and paste [[File:Hong_Kong_Skyline_Restitch_-_Dec_2007.jpg|thumb|300]] into http://en.wiki.local.wmftest.net:8080/w/index.php?title=Hong_Kong&action=edit
I expect to see a thumbnail generated.
The url generated 404s /images/thumb/2/23/Hong_Kong_Skyline_Restitch_-_Dec_2007.jpg/300px-Hong_Kong_Skyline_Restitch_-_Dec_2007.jpg

This impacts development of the WikidataPageBannerExtension
The same problem can be replicated by setting $wgPBImage = 'Manhattan4_amk.jpg'; which causes the page banner to 404 as it generates a url to http://en.wiki.local.wmftest.net:8080/images/thumb/d/d7/Manhattan4_amk.jpg/320px-Manhattan4_amk.jpg

This is similar to T56202 but also happens when the 404 handler is not enabled, and it only affects non-default wikis (ie. InstantComons still works on 127.0.0.1).

Event Timeline

Jdlrobson raised the priority of this task from to Needs Triage.
Jdlrobson updated the task description. (Show Details)
Jdlrobson moved this task to In discussion on the Wikidata-Page-Banner board.
Jdlrobson subscribed.
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Jdlrobson moved this task from In discussion to Backlog on the Wikidata-Page-Banner board.
Jdlrobson set Security to None.

I tried this exhaustively with a number of images and mostly it returns an error:

Fatal error: Call to a member function getUrl() on a non-object in /vagrant/mediawiki/extensions/WikidataPageBanner/includes/WikidataPageBanner.hooks.php on line 123

However sometimes, there's no error.
The only possible reason I can find for this is that the method WikidataPageBanner::getBannerUrl() is generating banners of 4 different widths and returning their urls and does this using api requests in case of a Foreign file. Its probable that "$mto->transform()" does not return on time and consequently the transformation result is null, which is the above error.
A probable solution in case of a foreign file is to load a small default image and generate the full srcset on client-side using javascript.

Looks like the generation of "srcset" will have to be moved to client side. Since the wiki is querying for the urls through api requests to commons, doing this task on client side seems feasible.

Let me see what's happening here.

Jdlrobson added a project: MediaWiki-Vagrant.
Jdlrobson added a subscriber: bd808.

@bd808 anything obvious you can think of that might cause this?

There have been reports in the past that $wgUseInstantCommons is broken in MediaWiki-Vagrant. I'd have to admit to not making use of it often. I did however just paste the provided file link ([[File:Hong_Kong_Skyline_Restitch_-_Dec_2007.jpg|thumb|300px]]) into my local mw-vagrant install and it worked as expected.

My vagrant roles list -e output is:

Enabled roles:

centralauth                oauth                      sitematrix
fss                        parserfunctions            wikidiff2
gather                     poolcounter                wikimediamessages
l10nupdate                 scribunto

I don't see anything in there that would obviously make InstantCommons work or not work. It should be enabled by default and working AFAIK.

Enable the wikidata role and try it on http://en.wiki.local.wmftest.net:8080
I think that might be setup incorrectly...

Enable the wikidata role and try it on http://en.wiki.local.wmftest.net:8080
I think that might be setup incorrectly...

After enabling wikidata I can still add media to the default wiki as InstantCommons imports, but the local enwiki isn't showing such media unless the same image is imported into the default wiki. This sounds like a config problem for the tertiary wikis where we change $wgUploadDirectory and $wgCacheDirectory (see settings.d/wikis/enwiki/wgConf.php).

The real problem here is that the wikis are configured to use separate $wgUploadDirectory locations but there is no corresponding $wgUploadPath or Apache configuration.

Change 217769 had a related patch set uploaded (by BryanDavis):
Setup $wgUploadPath and apache for each wiki

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

This patch somewhat fixes it but it seems to only work for the general case [[File:2 Bloomsbury Square.jpg]] but not [[File:2 Bloomsbury Square.jpg|thumb|300]]

This patch somewhat fixes it but it seems to only work for the general case [[File:2 Bloomsbury Square.jpg]] but not [[File:2 Bloomsbury Square.jpg|thumb|300]]

When I was testing locally it seemed to not fix images/thumbs that had been already used in the wiki. It looked like something had stored the value of $wgUploadPath at the time that the image was originally imported.

There have been reports in the past that $wgUseInstantCommons is broken in MediaWiki-Vagrant.

That's T56202. It affects wikis with a 404 handler enabled (that's typically when you enable one of the multimedia roles). IIRC it has something to do with cached thumbnails ending up in the wrong directory.

There have been reports in the past that $wgUseInstantCommons is broken in MediaWiki-Vagrant.

That's T56202. It affects wikis with a 404 handler enabled (that's typically when you enable one of the multimedia roles). IIRC it has something to do with cached thumbnails ending up in the wrong directory.

That could actually be related to this fix then. We were certainly not setting up $wgUploadPath properly for the non-default wikis.

T56202 affects the default wiki as well.

Tgr updated the task description. (Show Details)

Change 217769 merged by jenkins-bot:
Setup $wgUploadPath and apache for each wiki

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

@Jdlrobson can you verify if this is fixed? (For normal pages you need to edit and save the page after vagrant provision for the fix to take effect. Not sure about the page banner.)

For some reason I cannot set $wgUseInstantCommons to true despite having a line in my LocalSettings.php ..
Want to troubleshoot over at my desk?

It's working! Yay :)