Page MenuHomePhabricator

Unable to override cores default mediahandlers
Closed, ResolvedPublic


$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

Event Timeline

Reedy created this task.Jul 25 2016, 8:55 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJul 25 2016, 8:55 PM
Reedy added a comment.Jul 25 2016, 8:59 PM

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] );

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 claimed this task.Jul 26 2016, 12:27 AM
Legoktm triaged this task as Normal priority.

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

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

Legoktm closed this task as Resolved.Aug 4 2016, 4:25 PM