Page MenuHomePhabricator

TimedMediaHandler breaks UploadWizard if $wgFileExtensions redefined...
Closed, ResolvedPublic

Description

In your LocalSettings.php, if you configure things in the following order:
1 - require_once("$IP/extensions/UploadWizard/UploadWizard.php");
2 - require_once("$IP/extensions/TimedMediaHandler/TimedMediaHandler.php");
3 - $wgFileExtensions = array_merge( $wgFileExtensions, array( 'doc', 'docx' ) );

Then, you won't be able to use the UploadWizard *at all*. If will always fail with the following javascript error:
This wiki does not accept filenames that end in the extension ".xxx".

If you change $wgFileExtensions before requiring TimedMediaHandler.php, then it works like a charm.

MediaWiki 1.21.2
PHP 5.3.10-1ubuntu3.8 (fpm-fcgi)
MySQL 5.5.28-0ubuntu0.12.04.2
Upload Wizard (Version 1.3)
TimedMediaHandler (Version 0.3)


Version: master
Severity: minor

Details

Reference
bz55366

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 2:37 AM
bzimport set Reference to bz55366.

This is because TimedMediaHandler touches the $wgFileExtensions array in an inappropriate way.

		// Remove mp4 if not enabled:
		if( $wgTmhEnableMp4Uploads === false ){
			foreach( $wgFileExtensions as $inx => $val ) {
				if( $val == 'mp4' ){
					unset( $wgFileExtensions[$inx] );
				}
			}
		}

This piece of code causes a certain value in that array to be missing. PHP accepts it (since its arrays are also maps), but this results in the array being serialized to JavaScript as an object, not an array, breaking UploadWizard which expects the latter.

Change 87715 had a related patch set uploaded by Bartosz Dziewoński:
Don't break $wgFileExtensions structure when removing 'mp4'

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

Change 87715 merged by jenkins-bot:
Don't break $wgFileExtensions structure when removing 'mp4'

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

Done. I wonder if it should be backported to the 1.21 branch? Is the 'master' version of TimedMediaHandler compatible with MediaWiki 1.21? (Kelson?)

Change 132167 had a related patch set uploaded by MarkAHershberger:
Don't break $wgFileExtensions structure when removing 'mp4'

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

Change 132170 had a related patch set uploaded by MarkAHershberger:
Don't break $wgFileExtensions structure when removing 'mp4'

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

The cherry picks that did work resulted in failing tests. That means this is available if someone wants to look into it, but I cannot spend more time on it right now.

Change 132170 abandoned by MarkAHershberger:
Don't break $wgFileExtensions structure when removing 'mp4'

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

Change 132167 abandoned by MarkAHershberger:
Don't break $wgFileExtensions structure when removing 'mp4'

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

Gilles raised the priority of this task from Medium to Unbreak Now!.Dec 4 2014, 10:20 AM
Gilles added a project: Multimedia.
Gilles moved this task from Untriaged to Done on the Multimedia board.
Gilles lowered the priority of this task from Unbreak Now! to Medium.Dec 4 2014, 11:21 AM