Page MenuHomePhabricator

Fix $this->file hard dependency on PageImages extension
Closed, ResolvedPublic

Description

If a file is given, whether or not the PageImages extension is installed, use the given file. Except there is no file and there is a page images extension installed, use PageImages to generate and set $this->file.

So if all conditions above fail, just return false as the default.

Event Timeline

D3r1ck01 created this task.Nov 17 2018, 4:13 PM
D3r1ck01 triaged this task as Normal priority.
D3r1ck01 moved this task from Backlog to Doing [WIP] on the User-D3r1ck01 board.

Change 474472 had a related patch set uploaded (by D3r1ck01; owner: Alangi Derick):
[mediawiki/extensions/MobileFrontend@master] Fix $this->file hard dependency on PageImages extension

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

So we've got a patch up to fix the hard dependency issue :), let's see how it goes, I'll continue with the parent patch that will depend on this :)

Finally tracked it down, this is the code causing us problems @Jdlrobson

if ( $this->usePageImages ) {
	$file = $this->file;
	if ( $file ) {
		$thumb = $file->transform( [ 'width' => $size ] );
		if ( $thumb && $thumb->getUrl() ) {
			$className = 'list-thumb ';
			$className .= $thumb->getWidth() > $thumb->getHeight()
				? 'list-thumb-y'
				: 'list-thumb-x';
			$props = [
				'class' => $className,
			];

			$imgUrl = wfExpandUrl( $thumb->getUrl(), PROTO_CURRENT );
			if ( $useBackgroundImage ) {
				$props['style'] = 'background-image: url("' . wfExpandUrl( $imgUrl, PROTO_CURRENT ) . '")';
				$text = '';
			} else {
				$props['src'] = $imgUrl;
				$text = $this->title->getText();
			}
			$imageHtml = Html::element( $useBackgroundImage ? 'div' : 'img', $props, $text );
		}
	}
}

It's in MobilePage and that code only runs when the PageImages is installed as it checks if ( $this->usePageImages ). Why so? I mean if a file is given, then do it as we mustn't have PI installed, changing that code now to complete the pending patch for this issue :), wow

Change 474472 abandoned by D3r1ck01:
Fix $this->file hard dependency on PageImages extension

Reason:
In favor of I6b40dfd8ed2403f1e0d4c4410d31356ea2493916.

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

D3r1ck01 reassigned this task from D3r1ck01 to pmiazga.Nov 20 2018, 9:09 PM
Jdlrobson closed this task as Resolved.Nov 21 2018, 12:06 AM

LGTM