Page MenuHomePhabricator

Unable to override cores default mediahandlers
Closed, ResolvedPublic

Description

$wgMediaHandlers = [
	'image/jpeg' => 'JpegHandler',
	'image/png' => 'PNGHandler',
	'image/gif' => 'GIFHandler',
	'image/tiff' => 'TiffHandler',
	'image/webp' => 'WebPHandler',
	'image/x-ms-bmp' => 'BmpHandler',
	'image/x-bmp' => 'BmpHandler',
	'image/x-xcf' => 'XCFHandler',
	'image/svg+xml' => 'SvgHandler', // official
	'image/svg' => 'SvgHandler', // compat
	'image/vnd.djvu' => 'DjVuHandler', // official
	'image/x.djvu' => 'DjVuHandler', // compat
	'image/x-djvu' => 'DjVuHandler', // compat
];

Core defines a image/tiff handler, but so does PagedTiffHandler. But you cannot override it, it's silently ignored

Related Objects

View Standalone Graph
This task is connected to more than 200 other tasks. Only direct parents and subtasks are shown here. Use View Standalone Graph to show more of the graph.

Event Timeline

I suspect this probably affects some of the other $globalSettings, but we haven't found that out yet ;)

				case 'array_merge':
					$GLOBALS[$key] = array_merge( $val, $GLOBALS[$key] );
					break;

The context here is that we want anything set in LocalSettings.php to win. That's $GLOBALS[$key]. But, that's also the DefaultSettings.php defaults.

We want a priority order of LocalSettings.php -> extension.json -> DefaultSettings.php, but because LocalSettings.php and DefaultSettings.php are merged before extension.json, we actually have LocalSettings.php -> DefaultSettings.php -> extension.json

The best thing to do here is to move the defaults into a MediaHandler class or wherever it gets read from, and combine the arrays in our preferred order at runtime. We've done this for LocalisationCache/$wgMessagesDirs as well, and that gets us O(1) performance too.

Legoktm triaged this task as Medium priority.

Change 301042 had a related patch set uploaded (by Legoktm):
Move MediaHandler defaults out of global scope

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

Eh, this is going to be a bigger refactoring than I thought.

Change 301042 merged by jenkins-bot:
Move MediaHandler defaults out of global scope

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