Page MenuHomePhabricator

PronunciationRecording uses UploadWizard in a very unsupported way
Open, MediumPublic

Description

PronunciationRecording uses UploadWizard in a very unsupported way. I just happened to find this when grepping all extensions, just in case, for usages of a feature we're planning to remove.

[extensions/PronunciationRecording]/resources/ext.pronunciationRecording.pronunciationRecorder.js
			startUploading: function ( ok, error, fileDetails ) {
				var config, uploadWizard, filesDiv;
				config = { enableFormData: true };
				filesDiv = document.createElement( 'div' );
				uploadWizard = new mw.UploadWizard( config );
				uploadWizardUpload = new mw.UploadWizardUpload( uploadWizard, filesDiv );

				// XXX: Hacks until UploadWizard can be better refactored
				// or there is a separate client-side upload library
				uploadWizardUpload.deedPreview = {
					setup: $.noop
				};

				uploadWizardUpload.details = {
					populate: $.noop
				};
				getBlob(
					function ( blob ) {
						uploadWizardUpload.file = blob;
						uploadWizardUpload.file.name = 'upload.wav';
						uploadHandler = uploadWizardUpload.getUploadHandler();
						uploadHandler.start();
						$.subscribeReady( 'thumbnails.' + uploadWizardUpload.index, function () {
							publishUpload( ok, error, fileDetails );
						} );
					}
				);
			}

I'm pretty sure this is already broken (we removed the 'thumbnails.' + uploadWizardUpload.index thing a while ago and I really did not expect that someone somewhere is using it).

Luckily, there is now a "separate client-side upload library"! It's called mw.Upload and it powers the upload dialog, where it works well. It should work for PronunciationRecording too.