Page MenuHomePhabricator

Filename scraping for image viewer should support ugly URLs
Closed, DuplicatePublic

Description

Set $wgUsePathInfo = true; and $wgArticlePath = "$wgScript?title=$1";
Visit a page in the wiki that has an image
Click an image on that page
Expected: Image shows in media viewer
Actual: Media viewer loads but no image ever displays

Original report / additional information:
When the wiki uses ugly URLs, e.g. index.php?title=File:... or (verify this) index.php/File:... the viewer fails to scrape the filename properly, failing to show it. Sample API request:

api.php?action=query&format=json&prop=imageinfo&titles=index.php%3Ftitle%3DFile%3ACiambella_ricotta_claudia_fine.jpg&iiprop=url|extmetadata&iiurlwidth=1920&iiurlheight=640

{"query":{"normalized":[{"from":"index.php?title=File:Ciambella_ricotta_claudia_fine.jpg","to":"Index.php?title=File:Ciambella ricotta claudia fine.jpg"}],"pages":{"-1":{"ns":0,"title":"Index.php?title=File:Ciambella ricotta claudia fine.jpg","missing":""}}}}

Event Timeline

MaxSem raised the priority of this task from to Needs Triage.
MaxSem updated the task description. (Show Details)
MaxSem added a project: Web-Team-Backlog.
MaxSem subscribed.

I don't understand this bug could you reword it?

Hi, the bug is present on ugly url setting, so standard installation. I checked on MW 1.24.1

Viewing the images there is a problem with selecting the images (see code posted extracted from Browser console) that make the browser never loading the images and keep loading.

On nice url it isn't happening.

MediaWiki 1.24.1
PHP 5.4.35 (cgi-fcgi)
MySQL 5.5.40-36.1-log

Entry point:
Percorso voci /ricette/index.php?title=$1
Percorso script /ricette
index.php /ricette/index.php
api.php /ricette/api.php
load.php /ricette/load.php

MaxSem renamed this task from Filename scraping for image viewer should support to Filename scraping for image viewer should support ugly URLs.Jan 20 2015, 11:41 PM
MaxSem set Security to None.

I still don't really understand this... Can you provide some clear steps to replicate?

Yes, try it on a wiki without pretty URLs, i.e. default MW install without rewrites.

Have you figured it out? if you sill need additional information feel free to ask.

Apologies, and thanks for your patience. Sorry there are lots of bugs to wrangle my head round and I haven't had time to personally investigate - so treat me like I'm stupid and make this as easy as possible to replicate :) - I'm not familiar with MediaWiki's url rewriting.

I'm assuming there is an issue when you click the image on a page on your wiki? What happens? Does a broken image overlay load, a broken image or nothing at all?

Are these the steps to reproduce?:

Expected: Image shows
Actual: Broken image displays (is this correct?)

If so all I need for completeness is to know

Exactly, look at the screenshot, i clicked on thst image and the mobile is broken on loading

http://i59.tinypic.com/v4osk8.png
http://i60.tinypic.com/wit6kn.png

Now I am out, i will have a look within one hour on the code.

Thx

If so all I need for completeness is to know

to use the wiki with ugly url at all add these lines (or modify) on localsettings.php:

$wgUsePathInfo = true;
$wgArticlePath = "$wgScript?title=$1";

and you have to check using mobile phone. For istance I cannot replicate the problem using laptop on mobile view active.
But it happens on my smartphone.
EDIT: sorry it happens even on mobile view using laptop

Jdlrobson raised the priority of this task from Low to Medium.Aug 20 2015, 3:34 PM
Jdlrobson updated the task description. (Show Details)

hi,

without doing nothing to configuration file:

this is working (I wrote it myself typing):
http://www.valeriocipriani.com/ricette/index.php?title=Bab%C3%A0#/media/File:Bab%C3%A0_fine.jpg

this link is not working (this is the automatic generated one)
http://www.valeriocipriani.com/ricette/index.php?title=Bab%C3%A0#/media/index.php?title=File:Bab%C3%A0_fine.jpg

EIDT:
so I temporarily fixed doing this:

on /extensions/MobileFrontend/javascripts/modules/mediaViewer/init.js

find

	function onClickImage( ev ) {
		ev.preventDefault();
		router.navigate( '#/media/' + $( this ).data( 'thumb' ).getFileName() );
	}

replace

	function onClickImage( ev ) {
		ev.preventDefault();
		var fixed_image_ugly = ( '#/media/' + $( this ).data( 'thumb' ).getFileName() );
		fixed_image_ugly = fixed_image_ugly.replace('index.php?title=', '')
		fixed_image_ugly = fixed_image_ugly.replace('?title=', '')
		router.navigate(fixed_image_ugly);
	}

the first is the problem on my webserver, the second on wamp default install apache.

hi,

the problem is still there, but I am fixing it editing the file:
\resources\skins.minerva.scripts\init.js

on my MW 1.27.0 and last stable mobilefrontend

	function onClickImage( ev ) {
		ev.preventDefault();
	//	router.navigate( '#/media/' + encodeURIComponent( $( this ).data( 'thumb' ).getFileName() ) );
// Fix Begin
		var fixed_image_ugly = ( '#/media/' + $( this ).data( 'thumb' ).getFileName() );
		fixed_image_ugly = fixed_image_ugly.replace('index.php?title=', '')
		fixed_image_ugly = fixed_image_ugly.replace('?title=', '')
		router.navigate(fixed_image_ugly);
// Fix End
	}

HI @Raid thanks for the patch. Are you able to submit it to Gerrit or upload a patch file? If so I'll happily review.

It might be possible to use mw.config.get( 'wgArticlePath' ) to get at the index.php portion.

Hi,

I never used Gerrit, I will take a look.

thx