Page MenuHomePhabricator

"View author information" URL doesn't update when navigating between images
Closed, ResolvedPublicBUG REPORT

Description

List of steps to reproduce (step by step, including full links if applicable):

What happens?:
The "View author information" URL does not update. It uses the URL from the first image for all subsequent images that use the "View author information" fallback.

T308958.png (210×653 px, 29 KB)

What should have happened instead?:
The "View author information" URL should update for each image.

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc.:
1.39.0-wmf.12. Also observed in 1.35.6 bundled extension.

Event Timeline

This is due to cached HTML from the previous image being returned:

	/**
	 * Returns the text content of a html string, with the `<a>`, `<i>`, `<b>` tags left intact.
	 * Tries to give an approximation of what would be visible if the HTML would be displayed.
	 *
	 * @param {string} html
	 * @return {string}
	 */
	HUP.htmlToTextWithTags = function ( html ) {
		var $html;
		if ( !cache.textWithTags[ html ] ) {
			$html = this.wrapAndJquerify( html );
			this.filterInvisible( $html );
			this.appendWhitespaceToBlockElements( $html );
			this.whitelistHtml( $html, 'a, span, i, b, sup, sub' );
			cache.textWithTags[ html ] = this.mergeWhitespace( $html.html() );
		}
		return cache.textWithTags[ html ];
	};

jQuery object gets converted to array key [object Object] which results in ununique key and causes incorrect cached HTML to be returned:

} else {
	this.creditField.set(
		$( '<a>' )
			.addClass( 'mw-mmv-credit-fallback' )
			.prop( 'href', filepageUrl )
			.text( mw.message( 'multimediaviewer-credit-fallback' ).plain() )
	);
}
Object { "Test": "Test", "[object Object]": "<a class=\"mw-mmv-credit-fallback\" href=\"http://localhost:8080/wiki/File:Test.PNG\">View author information</a>", Capture: "Capture" }
mmv.HtmlUtils.js:234:11

Change 803612 had a related patch set uploaded (by Dylsss; author: Dylsss):

[mediawiki/extensions/MultimediaViewer@master] Fix credit fallback not updating when switching image

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

Change 803612 merged by jenkins-bot:

[mediawiki/extensions/MultimediaViewer@master] Fix credit fallback not updating when switching image

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