TheDJ has uploaded a new change for review. https://gerrit.wikimedia.org/r/284929
Change subject: Convert to short form array ...................................................................... Convert to short form array Change-Id: I221b5fe3c214cbc61f2f8d413883c5f280e1b84a --- M ApiTranscodeReset.php M ApiTranscodeStatus.php M SpecialOrphanedTimedText.php M SpecialTimedMediaHandler.php M TimedMediaHandler.hooks.php M TimedMediaHandler.php M TimedMediaHandler_body.php M TimedMediaIframeOutput.php M TimedMediaThumbnail.php M TimedMediaTransformOutput.php M TimedTextPage.php M TranscodeStatusTable.php M WebVideoTranscode/WebVideoTranscode.php M WebVideoTranscode/WebVideoTranscodeJob.php M composer.json M handlers/FLACHandler/FLACHandler.php M handlers/Mp4Handler/Mp4Handler.php M handlers/TextHandler/TextHandler.php M handlers/WAVHandler/WAVHandler.php M handlers/WebMHandler/WebMHandler.php M maintenance/cleanupTranscodes.php M maintenance/moveTranscoded.php M maintenance/resetTranscodes.php M maintenance/retryTranscodes.php M tests/phpunit/ApiTestCaseVideoUpload.php M tests/phpunit/TestOggHandler.php M tests/phpunit/TestTimedMediaHandler.php M tests/phpunit/TestTimedMediaTransformOutput.php M tests/phpunit/TestVideoThumbnail.php M tests/phpunit/TestVideoTranscode.php M tests/phpunit/TestWebMHandler.php 31 files changed, 563 insertions(+), 567 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TimedMediaHandler refs/changes/29/284929/1 diff --git a/ApiTranscodeReset.php b/ApiTranscodeReset.php index 3aedb47..787f7e6 100644 --- a/ApiTranscodeReset.php +++ b/ApiTranscodeReset.php @@ -24,11 +24,11 @@ // Make sure we have a valid Title $titleObj = Title::newFromText( $params['title'] ); if ( !$titleObj || $titleObj->isExternal() ) { - $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); + $this->dieUsageMsg( [ 'invalidtitle', $params['title'] ] ); } // Make sure the title can be transcoded if ( !TimedMediaHandlerHooks::isTranscodableTitle( $titleObj ) ) { - $this->dieUsageMsg( array( 'invalidtranscodetitle', $params['title'] ) ); + $this->dieUsageMsg( [ 'invalidtranscodetitle', $params['title'] ] ); } $transcodeKey = false; // Make sure its a enabled transcode key we are trying to remove: @@ -103,7 +103,7 @@ return $wgWaitTimeForTranscodeReset + 1; } // return wait time from most recent event - foreach ( array( 'time_success', 'time_startwork', 'time_addjob' ) as $timeField ) { + foreach ( [ 'time_success', 'time_startwork', 'time_addjob' ] as $timeField ) { if ( !is_null( $state[ $timeField ] ) ) { return $db->timestamp() - $db->timestamp( $state[ $timeField ] ); } @@ -128,25 +128,25 @@ } protected function getAllowedParams() { - return array( - 'title' => array( + return [ + 'title' => [ ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_REQUIRED => true - ), + ], 'transcodekey' => null, 'token' => null, - ); + ]; } /** * @deprecated since MediaWiki core 1.25 */ protected function getParamDescription() { - return array( + return [ 'title' => 'The media file title', 'transcodekey' => 'The transcode key you wish to reset', 'token' => 'An edit token obtained via action=tokens', - ); + ]; } public function needsToken() { diff --git a/ApiTranscodeStatus.php b/ApiTranscodeStatus.php index 360b6b5..a2e4d45 100644 --- a/ApiTranscodeStatus.php +++ b/ApiTranscodeStatus.php @@ -30,8 +30,8 @@ unset( $val['image_name'] ); unset( $val['key'] ); } - $result->addValue( array( - 'query', 'pages', $img->getTitle()->getArticleID() ), 'transcodestatus', $transcodeStatus + $result->addValue( [ + 'query', 'pages', $img->getTitle()->getArticleID() ], 'transcodestatus', $transcodeStatus ); } } @@ -43,34 +43,34 @@ } public function getAllowedParams() { - return array(); + return []; } /** * @deprecated since MediaWiki core 1.25 */ public function getDescription() { - return array( + return [ 'Get transcode status for a given file page' - ); + ]; } /** * @deprecated since MediaWiki core 1.25 */ protected function getExamples() { - return array( + return [ 'api.php?action=query&prop=transcodestatus&titles=File:Clip.webm', - ); + ]; } /** * @see ApiBase::getExamplesMessages() */ protected function getExamplesMessages() { - return array( + return [ 'action=query&prop=transcodestatus&titles=File:Clip.webm' => 'apihelp-query+transcodestatus-example-1', - ); + ]; } } diff --git a/SpecialOrphanedTimedText.php b/SpecialOrphanedTimedText.php index aa93e3b..2eb57a4 100644 --- a/SpecialOrphanedTimedText.php +++ b/SpecialOrphanedTimedText.php @@ -124,16 +124,16 @@ * @return Array Standard query info values. */ function getQueryInfo() { - $tables = array( 'page', 'image' ); - $fields = array( + $tables = [ 'page', 'image' ]; + $fields = [ 'namespace' => 'page_namespace', 'title' => 'page_title', 'value' => 0, - ); - $conds = array( + ]; + $conds = [ 'img_name' => null, 'page_namespace' => NS_TIMEDTEXT, - ); + ]; // Now for the complicated bit // Note: This bit is mysql specific. Probably could do something @@ -142,22 +142,22 @@ // this in standard sql, or in sqlite. $baseCond = 'substr( page_title, 1, length( page_title ) - ' . "length( substring_index( page_title, '.' ,-2 ) ) - 1 )"; - $joinConds = array( - 'image' => array( + $joinConds = [ + 'image' => [ 'LEFT OUTER JOIN', $baseCond . ' = img_name' - ) - ); - return array( + ] + ]; + return [ 'tables' => $tables, 'fields' => $fields, 'conds' => $conds, 'join_conds' => $joinConds - ); + ]; } public function getOrderFields() { - return array( 'namespace', 'title' ); + return [ 'namespace', 'title' ]; } /** @@ -215,14 +215,14 @@ return; } - $filesToLookFor = array(); + $filesToLookFor = []; foreach ( $res as $row ) { $title = Title::makeTitle( $row->namespace, $row->title ); $fileTitle = $this->getCorrespondingFile( $title ); if ( !$fileTitle ) { continue; } - $filesToLookFor[] = array( 'title' => $fileTitle, 'ignoreRedirect' => true ); + $filesToLookFor[] = [ 'title' => $fileTitle, 'ignoreRedirect' => true ]; } $this->existingFiles = RepoGroup::singleton()->getLocalRepo()->findFiles( $filesToLookFor ); $res->seek( 0 ); @@ -251,7 +251,7 @@ } return $link; } else { - return Html::element( 'span', array( 'class' => 'mw-invalidtitle' ), + return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ], Linker::getInvalidTitleDescription( $this->getContext(), $row->namespace, $row->title ) ); } } diff --git a/SpecialTimedMediaHandler.php b/SpecialTimedMediaHandler.php index 31954ab..d929d57 100644 --- a/SpecialTimedMediaHandler.php +++ b/SpecialTimedMediaHandler.php @@ -17,16 +17,16 @@ 'missing' => 'transcode_time_addjob IS NULL', ); // @codingStandardsIgnoreEnd - private $formats = array( + private $formats = [ 'ogg' => 'img_major_mime="application" AND img_minor_mime = "ogg"', 'webm' => 'img_major_mime="video" AND img_minor_mime = "webm"', - ); - private $audioFormats = array( + ]; + private $audioFormats = [ 'ogg' => 'img_major_mime="application" AND img_minor_mime = "ogg"', 'webm' => 'img_major_mime="audio" AND img_minor_mime = "webm"', 'flac' => 'img_major_mime="audio" AND img_minor_mime="x-flac"', 'wav' => 'img_major_mime="audio" AND img_minor_mime="wav"', - ); + ]; public function __construct( $request = null, $par = null ) { parent::__construct( 'TimedMediaHandler', 'transcode-status' ); @@ -40,7 +40,7 @@ $stats = $this->getStats(); - foreach ( array( 'audios', 'videos' ) as $type ) { + foreach ( [ 'audios', 'videos' ] as $type ) { // for grep timedmedia-audios, timedmedia-videos $out->addHTML( "<h2>" @@ -111,16 +111,16 @@ $files = $wgMemc->get( $memcKey ); if ( !$files ) { $dbr = wfGetDB( DB_SLAVE ); - $files = array(); + $files = []; $res = $dbr->select( 'transcode', '*', $this->transcodeStates[ $state ], __METHOD__, - array( 'LIMIT' => $limit, 'ORDER BY' => 'transcode_time_error DESC' ) + [ 'LIMIT' => $limit, 'ORDER BY' => 'transcode_time_error DESC' ] ); foreach ( $res as $row ) { - $transcode = array(); + $transcode = []; foreach ( $row as $k => $v ) { $transcode[ str_replace( 'transcode_', '', $k ) ] = $v; } @@ -161,8 +161,8 @@ $stats = $wgMemc->get( $memcKey ); if ( !$stats ) { $dbr = wfGetDB( DB_SLAVE ); - $stats = array(); - $stats[ 'videos' ] = array( 'total' => 0 ); + $stats = []; + $stats[ 'videos' ] = [ 'total' => 0 ]; foreach ( $this->formats as $format => $condition ) { $stats[ 'videos' ][ $format ] = (int)$dbr->selectField( 'image', @@ -172,7 +172,7 @@ ); $stats[ 'videos' ][ 'total' ] += $stats[ 'videos' ][ $format ]; } - $stats[ 'audios' ] = array( 'total' => 0 ); + $stats[ 'audios' ] = [ 'total' => 0 ]; foreach ( $this->audioFormats as $format => $condition ) { $stats[ 'audios' ][ $format ] = (int)$dbr->selectField( 'image', @@ -194,10 +194,10 @@ $states = $wgMemc->get( $memcKey ); if ( !$states ) { $dbr = wfGetDB( DB_SLAVE ); - $states = array(); - $states[ 'transcodes' ] = array( 'total' => 0 ); + $states = []; + $states[ 'transcodes' ] = [ 'total' => 0 ]; foreach ( $this->transcodeStates as $state => $condition ) { - $states[ $state ] = array( 'total' => 0 ); + $states[ $state ] = [ 'total' => 0 ]; foreach ( $allTranscodes as $type ) { // Important to pre-initialize, as can give // warnings if you don't have a lot of things in transcode table. @@ -205,13 +205,13 @@ } } foreach ( $this->transcodeStates as $state => $condition ) { - $cond = array( 'transcode_key' => $allTranscodes ); + $cond = [ 'transcode_key' => $allTranscodes ]; $cond[] = $condition; $res = $dbr->select( 'transcode', - array( 'COUNT(*) as count', 'transcode_key' ), + [ 'COUNT(*) as count', 'transcode_key' ], $cond, __METHOD__, - array( 'GROUP BY' => 'transcode_key' ) + [ 'GROUP BY' => 'transcode_key' ] ); foreach ( $res as $row ) { $key = $row->transcode_key; @@ -220,10 +220,10 @@ } } $res = $dbr->select( 'transcode', - array( 'COUNT(*) as count', 'transcode_key' ), - array( 'transcode_key' => $allTranscodes ), + [ 'COUNT(*) as count', 'transcode_key' ], + [ 'transcode_key' => $allTranscodes ], __METHOD__, - array( 'GROUP BY' => 'transcode_key' ) + [ 'GROUP BY' => 'transcode_key' ] ); foreach ( $res as $row ) { $key = $row->transcode_key; diff --git a/TimedMediaHandler.hooks.php b/TimedMediaHandler.hooks.php index 9e7c94e..81fdc3a 100644 --- a/TimedMediaHandler.hooks.php +++ b/TimedMediaHandler.hooks.php @@ -34,66 +34,66 @@ public static function resourceLoaderRegisterModules( &$resourceLoader ) { global $wgTmhWebPlayer; - $baseExtensionResource = array( + $baseExtensionResource = [ 'localBasePath' => __DIR__, 'remoteExtPath' => 'TimedMediaHandler', - ); + ]; if ( $wgTmhWebPlayer === 'mwembed' ) { - $resourceModules = array( - 'mw.PopUpMediaTransform' => $baseExtensionResource + array( + $resourceModules = [ + 'mw.PopUpMediaTransform' => $baseExtensionResource + [ 'scripts' => 'resources/mw.PopUpThumbVideo.js', - 'dependencies' => array( + 'dependencies' => [ 'mw.MwEmbedSupport', 'mediawiki.Title', 'mw.PopUpMediaTransform.styles' - ), + ], 'position' => 'top', - ), - 'mw.PopUpMediaTransform.styles' => $baseExtensionResource + array( + ], + 'mw.PopUpMediaTransform.styles' => $baseExtensionResource + [ 'position' => 'top', 'styles' => 'resources/PopUpThumbVideo.css', - ), - 'mw.TMHGalleryHook.js' => $baseExtensionResource + array( + ], + 'mw.TMHGalleryHook.js' => $baseExtensionResource + [ 'scripts' => 'resources/mw.TMHGalleryHook.js', // position top needed as it needs to load before mediawiki.page.gallery 'position' => 'top', - ), - 'embedPlayerIframeStyle'=> $baseExtensionResource + array( + ], + 'embedPlayerIframeStyle'=> $baseExtensionResource + [ 'styles' => 'resources/embedPlayerIframe.css', 'position' => 'bottom', - ), - 'ext.tmh.embedPlayerIframe' => $baseExtensionResource + array( + ], + 'ext.tmh.embedPlayerIframe' => $baseExtensionResource + [ 'scripts' => 'resources/ext.tmh.embedPlayerIframe.js', - 'dependencies' => array( + 'dependencies' => [ 'jquery.embedPlayer', 'mw.MwEmbedSupport', - ), - ), - "mw.MediaWikiPlayerSupport" => $baseExtensionResource + array( + ], + ], + "mw.MediaWikiPlayerSupport" => $baseExtensionResource + [ 'scripts' => 'resources/mw.MediaWikiPlayerSupport.js', - 'dependencies'=> array( + 'dependencies'=> [ 'mw.Api', 'mw.MwEmbedSupport', - ), - ), + ], + ], // adds support MediaWikiPlayerSupport player bindings - "mw.MediaWikiPlayer.loader" => $baseExtensionResource + array( + "mw.MediaWikiPlayer.loader" => $baseExtensionResource + [ 'scripts' => 'resources/mw.MediaWikiPlayer.loader.js', - 'dependencies' => array( + 'dependencies' => [ "mw.EmbedPlayer.loader", "mw.TimedText.loader", - ), + ], 'position' => 'top', - ), - ); + ], + ]; } elseif ( $wgTmhWebPlayer === 'videojs' ) { - $resourceModules = array( - 'ext.tmh.video-js' => $baseExtensionResource + array( + $resourceModules = [ + 'ext.tmh.video-js' => $baseExtensionResource + [ 'scripts' => 'resources/videojs/video.js', 'styles' => 'resources/videojs/video-js.css', - 'targets' => array( 'mobile', 'desktop' ), - 'languageScripts' => array( + 'targets' => [ 'mobile', 'desktop' ], + 'languageScripts' => [ 'ar' => 'resources/videojs/lang/ar.js', 'ba' => 'resources/videojs/lang/ba.js', 'bg' => 'resources/videojs/lang/bg.js', @@ -123,16 +123,16 @@ 'vi' => 'resources/videojs/lang/vi.js', 'zh-CN' => 'resources/videojs/lang/zh-CN.js', 'zh-TW' => 'resources/videojs/lang/zh-TW.js', - ), - ), - 'ext.tmh.videojs-ogvjs' => $baseExtensionResource + array( + ], + ], + 'ext.tmh.videojs-ogvjs' => $baseExtensionResource + [ 'scripts' => 'resources/videojs-ogvjs/videojs-ogvjs.js', - 'targets' => array( 'mobile', 'desktop' ), - 'dependencies' => array( + 'targets' => [ 'mobile', 'desktop' ], + 'dependencies' => [ 'ext.tmh.video-js', 'ext.tmh.OgvJs', - ), - ), + ], + ], // 'ext.tmh.videojs-offset' => $baseExtensionResource + array( // 'scripts' => 'resources/videojs-offset/videojs-offset.js', // 'targets' => array( 'mobile', 'desktop' ), @@ -140,36 +140,36 @@ // 'ext.tmh.video-js', // ), // ), - 'ext.tmh.videojs-resolution-switcher' => $baseExtensionResource + array( + 'ext.tmh.videojs-resolution-switcher' => $baseExtensionResource + [ 'scripts' => 'resources/videojs-resolution-switcher/videojs-resolution-switcher.js', 'styles' => 'resources/videojs-resolution-switcher/videojs-resolution-switcher.css', - 'targets' => array( 'mobile', 'desktop' ), - 'dependencies' => array( + 'targets' => [ 'mobile', 'desktop' ], + 'dependencies' => [ 'ext.tmh.video-js', - ), - ), - 'ext.tmh.videojs-responsive-layout' => $baseExtensionResource + array( + ], + ], + 'ext.tmh.videojs-responsive-layout' => $baseExtensionResource + [ 'scripts' => 'resources/videojs-responsive-layout/videojs-responsive-layout.js', - 'targets' => array( 'mobile', 'desktop' ), - 'dependencies' => array( + 'targets' => [ 'mobile', 'desktop' ], + 'dependencies' => [ 'ext.tmh.video-js', - ), - ), - 'ext.tmh.player' => $baseExtensionResource + array( + ], + ], + 'ext.tmh.player' => $baseExtensionResource + [ 'scripts' => 'resources/ext.tmh.player.js', - 'targets' => array( 'mobile', 'desktop' ), - 'dependencies' => array( + 'targets' => [ 'mobile', 'desktop' ], + 'dependencies' => [ 'ext.tmh.video-js', 'ext.tmh.videojs-resolution-switcher', 'ext.tmh.videojs-ogvjs', 'ext.tmh.videojs-responsive-layout', // 'ext.tmh.videojs-offset', - ), - ), - 'ext.tmh.player.styles' => $baseExtensionResource + array( + ], + ], + 'ext.tmh.player.styles' => $baseExtensionResource + [ 'styles' => 'resources/ext.tmh.player.styles.less', - ) - ); + ] + ]; } $resourceLoader->register( $resourceModules ); @@ -238,24 +238,24 @@ // Transcode jobs must be explicitly requested from the job queue: $wgJobTypesExcludedFromDefaultQueue[] = 'webVideoTranscode'; - $baseExtensionResource = array( + $baseExtensionResource = [ 'localBasePath' => __DIR__, 'remoteExtPath' => 'TimedMediaHandler', - ); + ]; - $wgResourceModules += array( - 'ext.tmh.thumbnail.styles' => $baseExtensionResource + array( + $wgResourceModules += [ + 'ext.tmh.thumbnail.styles' => $baseExtensionResource + [ 'styles' => 'resources/ext.tmh.thumbnail.css', 'position' => 'top', - ), - 'ext.tmh.transcodetable' => $baseExtensionResource + array( + ], + 'ext.tmh.transcodetable' => $baseExtensionResource + [ 'scripts' => 'resources/ext.tmh.transcodetable.js', 'styles' => 'resources/transcodeTable.css', - 'dependencies' => array( + 'dependencies' => [ 'mediawiki.api.edit', 'oojs-ui', - ), - 'messages'=> array( + ], + 'messages'=> [ 'timedmedia-reset-button-cancel', 'timedmedia-reset-button-dismiss', 'timedmedia-reset-button-reset', @@ -263,27 +263,27 @@ 'timedmedia-reset', 'timedmedia-reset-areyousure', 'timedmedia-reset-explanation', - ) - ), - 'ext.tmh.TimedTextSelector' => $baseExtensionResource + array( + ] + ], + 'ext.tmh.TimedTextSelector' => $baseExtensionResource + [ 'scripts' => 'resources/ext.tmh.TimedTextSelector.js', - ), + ], // Add OgvJs-related modules for Safari/IE/Edge Ogg playback - 'ext.tmh.OgvJsSupport' => $baseExtensionResource + array( - 'scripts' => array( + 'ext.tmh.OgvJsSupport' => $baseExtensionResource + [ + 'scripts' => [ 'MwEmbedModules/EmbedPlayer/binPlayers/ogv.js/ogv-support.js', 'resources/ext.tmh.OgvJsSupport.js', - ), - 'targets' => array( 'mobile', 'desktop' ), - ), - 'ext.tmh.OgvJs' => $baseExtensionResource + array( - 'scripts' => array( + ], + 'targets' => [ 'mobile', 'desktop' ], + ], + 'ext.tmh.OgvJs' => $baseExtensionResource + [ + 'scripts' => [ 'MwEmbedModules/EmbedPlayer/binPlayers/ogv.js/ogv.js', - ), + ], 'dependencies' => 'ext.tmh.OgvJsSupport', - 'targets' => array( 'mobile', 'desktop' ), - ), - ); + 'targets' => [ 'mobile', 'desktop' ], + ], + ]; // Setup a hook for iframe embed handling: $wgHooks['ArticleFromTitle'][] = 'TimedMediaIframeOutput::iframeHook'; @@ -382,11 +382,11 @@ if ( $handler !== false && $handler instanceof TimedMediaHandler ) { if ( $wgTmhWebPlayer === 'mwembed' ) { $out->addModuleStyles( 'ext.tmh.thumbnail.styles' ); - $out->addModules( array( + $out->addModules( [ 'mw.MediaWikiPlayer.loader', 'mw.PopUpMediaTransform', 'mw.TMHGalleryHook.js', - ) ); + ] ); } elseif ( $wgTmhWebPlayer === 'videojs' ) { $out->addModuleStyles( 'ext.tmh.player.styles' ); $out->addModules( 'ext.tmh.player' ); @@ -594,7 +594,7 @@ */ public static function registerUnitTests( array &$files ) { $testDir = __DIR__ . '/tests/phpunit/'; - $testFiles = array( + $testFiles = [ 'TestTimeParsing.php', 'TestApiUploadVideo.php', 'TestVideoThumbnail.php', @@ -603,7 +603,7 @@ 'TestWebMHandler.php', 'TestTimedMediaTransformOutput.php', 'TestTimedMediaHandler.php' - ); + ]; foreach ( $testFiles as $fileName ) { $files[] = $testDir . $fileName; } @@ -652,10 +652,10 @@ if ( $wgTmhWebPlayer === 'mwembed' ) { $out->addModuleStyles( 'ext.tmh.thumbnail.styles' ); - $out->addModules( array( + $out->addModules( [ 'mw.MediaWikiPlayer.loader', 'mw.PopUpMediaTransform', - ) ); + ] ); } elseif ( $wgTmhWebPlayer === 'videojs' ) { $out->addModuleStyles( 'ext.tmh.player.styles' ); $out->addModules( 'ext.tmh.player' ); @@ -672,8 +672,8 @@ case 'sqlite': // Initial install tables $updater->addExtensionTable( 'transcode', "$base/TimedMediaHandler.sql" ); - $updater->addExtensionUpdate( array( 'addIndex', 'transcode', 'transcode_name_key', - "$base/archives/transcode_name_key.sql", true ) ); + $updater->addExtensionUpdate( [ 'addIndex', 'transcode', 'transcode_name_key', + "$base/archives/transcode_name_key.sql", true ] ); break; case 'postgres': // TODO @@ -683,7 +683,7 @@ } public static function onwgQueryPages( $qp ) { - $qp[] = array( 'SpecialOrphanedTimedText', 'OrphanedTimedText' ); + $qp[] = [ 'SpecialOrphanedTimedText', 'OrphanedTimedText' ]; return true; } diff --git a/TimedMediaHandler.php b/TimedMediaHandler.php index 6281dfd..68838b1 100644 --- a/TimedMediaHandler.php +++ b/TimedMediaHandler.php @@ -53,8 +53,8 @@ $wgMinimumVideoPlayerSize = 200; // Set the supported ogg codecs: -$wgMediaVideoTypes = array( 'Theora', 'VP8' ); -$wgMediaAudioTypes = array( 'Vorbis', 'Speex', 'FLAC', 'Opus' ); +$wgMediaVideoTypes = [ 'Theora', 'VP8' ]; +$wgMediaAudioTypes = [ 'Vorbis', 'Speex', 'FLAC', 'Opus' ]; // Default skin for mwEmbed player $wgVideoPlayerSkinModule = 'mw.PlayerSkinKskin'; @@ -106,7 +106,7 @@ // Set TimedText namespace for ForeignDBViaLBRepo on a per wikiID basis // $wgTimedTextForeignNamespaces = array( 'commonswiki' => 102 ); -$wgTimedTextForeignNamespaces = array(); +$wgTimedTextForeignNamespaces = []; // Set to false to disable local TimedText, // you still get subtitles for videos from foreign repos @@ -127,7 +127,7 @@ * -Derivative jobs are added to the MediaWiki JobQueue the first time the asset is displayed * -Derivative should be listed min to max */ -$wgEnabledTranscodeSet = array( +$wgEnabledTranscodeSet = [ // WebM VP8/Vorbis // primary free/open video format @@ -153,7 +153,6 @@ // A 4K full high quality WebM stream // WebVideoTranscode::ENC_WEBM_2160P, - // Ogg Theora/Vorbis // Fallback for Safari/IE/Edge with ogv.js @@ -201,9 +200,9 @@ // A 4K high quality stream; higher end phones, tablets, smart tvs WebVideoTranscode::ENC_H264_2160P, */ -); +]; -$wgEnabledAudioTranscodeSet = array( +$wgEnabledAudioTranscodeSet = [ WebVideoTranscode::ENC_OGG_VORBIS, // opus support must be available in avconv @@ -214,7 +213,7 @@ // avconv needs libvo_aacenc support // WebVideoTranscode::ENC_AAC, -); +]; // If mp4 source assets can be ingested: $wgTmhEnableMp4Uploads = false; @@ -226,11 +225,10 @@ /******************* CONFIGURATION ENDS HERE **********************/ - // List of extensions handled by Timed Media Handler since its referenced in a few places. // you should not modify this variable -$wgTmhFileExtensions = array( 'ogg', 'ogv', 'oga', 'flac', 'opus', 'wav', 'webm', 'mp4' ); +$wgTmhFileExtensions = [ 'ogg', 'ogv', 'oga', 'flac', 'opus', 'wav', 'webm', 'mp4' ]; $wgFileExtensions = array_merge( $wgFileExtensions, $wgTmhFileExtensions ); @@ -334,20 +332,20 @@ $wgSpecialPages['TimedMediaHandler'] = 'SpecialTimedMediaHandler'; // Extension Credits -$wgExtensionCredits['media'][] = array( +$wgExtensionCredits['media'][] = [ 'path' => __FILE__, 'name' => 'TimedMediaHandler', 'namemsg' => 'timedmediahandler-extensionname', - 'author' => array( + 'author' => [ 'Michael Dale', 'Tim Starling', 'James Heinrich', 'Jan Gerber', 'Brion Vibber', 'Derk-Jan Hartman' - ), + ], 'url' => 'https://www.mediawiki.org/wiki/Extension:TimedMediaHandler', 'descriptionmsg' => 'timedmediahandler-desc', 'version' => '0.5.0', 'license-name' => 'GPL-2.0+', -); +]; diff --git a/TimedMediaHandler_body.php b/TimedMediaHandler_body.php index 51620b1..b3419f8 100644 --- a/TimedMediaHandler_body.php +++ b/TimedMediaHandler_body.php @@ -27,13 +27,13 @@ * @return array */ function getParamMap() { - return array( + return [ 'img_width' => 'width', 'timedmedia_thumbtime' => 'thumbtime', 'timedmedia_starttime' => 'start', 'timedmedia_endtime' => 'end', 'timedmedia_disablecontrols' => 'disablecontrols', - ); + ]; } /** @@ -51,7 +51,7 @@ } elseif ( $name == 'disablecontrols' ) { $values = explode( ',', $value ); foreach ( $values as $v ) { - if ( !in_array( $v, array( 'options', 'timedText', 'fullscreen' ) ) ) { + if ( !in_array( $v, [ 'options', 'timedText', 'fullscreen' ] ) ) { return false; } } @@ -101,7 +101,7 @@ * @return array|bool Array of thumbnail parameters, or false if string cannot be parsed */ function parseParamString( $str ) { - $params = array(); + $params = []; if ( preg_match( '/^(mid|(\d*)px-)*(seek=([\d.]+))*$/', $str, $matches ) ) { $size = $thumbtime = null; if ( isset( $matches[2] ) ) { @@ -130,7 +130,7 @@ * @return bool */ function normaliseParams( $image, &$params ) { - $timeParam = array( 'thumbtime', 'start', 'end' ); + $timeParam = [ 'thumbtime', 'start', 'end' ]; // Parse time values if endtime or thumbtime can't be more than length -1 foreach ( $timeParam as $pn ) { if ( isset( $params[$pn] ) && $params[$pn] !== false ) { @@ -148,15 +148,15 @@ if ( $this->isAudio( $image ) ) { // Assume a default for audio files - $size = array( + $size = [ 'width' => 220, 'height' => 23, - ); + ]; } else { - $size = array( + $size = [ 'width' => $image->getWidth(), 'height' => $image->getHeight(), - ); + ]; } // Make sure we don't try and up-scale the asset: if ( !$this->isAudio( $image ) && isset( $params['width'] ) @@ -206,11 +206,11 @@ $parserOutput->hasTimedMediaTransform = true; if ( $wgTmhWebPlayer == 'mwembed' ) { $parserOutput->addModuleStyles( 'ext.tmh.thumbnail.styles' ); - $parserOutput->addModules( array( + $parserOutput->addModules( [ 'mw.MediaWikiPlayer.loader', 'mw.PopUpMediaTransform', 'mw.TMHGalleryHook.js', - ) ); + ] ); } elseif ( $wgTmhWebPlayer === 'videojs' ) { $parserOutput->addModuleStyles( 'ext.tmh.player.styles' ); $parserOutput->addModules( 'ext.tmh.player' ); @@ -258,7 +258,7 @@ * @return string */ public static function getTimePassedMsg( $timePassed ) { - $t = array(); + $t = []; $t['days'] = floor( $timePassed/60/60/24 ); $t['hours'] = floor( $timePassed/60/60 )%24; $t['minutes'] = floor( $timePassed/60 )%60; @@ -274,7 +274,7 @@ } } if ( count( $t ) == 0 ) { - $t = array( wfMessage( 'timedmedia-seconds', 0 )->text() ); + $t = [ wfMessage( 'timedmedia-seconds', 0 )->text() ]; } global $wgLang; @@ -338,7 +338,7 @@ * @return array */ function getThumbType( $ext, $mime, $params = null ) { - return array( 'jpg', 'image/jpeg' ); + return [ 'jpg', 'image/jpeg' ]; } /** @@ -376,7 +376,7 @@ $targetHeight = $params['height']; $targetWidth = round( $params['height'] * $srcWidth / $srcHeight ); } - $options = array( + $options = [ 'file' => $file, 'length' => $this->getLength( $file ), 'offset' => $this->getOffset( $file ), @@ -390,7 +390,7 @@ 'end' => isset( $params['end'] ) ? $params['end'] : false, 'fillwindow' => isset( $params['fillwindow'] ) ? $params['fillwindow'] : false, 'disablecontrols' => isset ( $params['disablecontrols'] ) ? $params['disablecontrols'] : false - ); + ]; // No thumbs for audio if ( !$options['isVideo'] ) { diff --git a/TimedMediaIframeOutput.php b/TimedMediaIframeOutput.php index 91efec5..0eb23a2 100644 --- a/TimedMediaIframeOutput.php +++ b/TimedMediaIframeOutput.php @@ -58,9 +58,9 @@ // file was removed, show wiki page with warning return false; } - $params = array( + $params = [ 'fillwindow' => true - ); + ]; $videoTransform = $file->transform( $params ); // Definitely do not want to break frames @@ -69,7 +69,7 @@ $wgOut->disallowUserJs(); if ( $wgTmhWebPlayer == 'mwembed' ) { - $wgOut->addModules( array( 'mw.MediaWikiPlayer.loader', 'ext.tmh.embedPlayerIframe' ) ); + $wgOut->addModules( [ 'mw.MediaWikiPlayer.loader', 'ext.tmh.embedPlayerIframe' ] ); } elseif ( $wgTmhWebPlayer === 'videojs' ) { $wgOut->addModuleStyles( 'ext.tmh.player.styles' ); $wgOut->addModules( 'ext.tmh.player' ); @@ -92,7 +92,7 @@ ); echo implode( "\n", $links["html"] ); - echo Html::element( 'meta', array( 'name' => 'ResourceLoaderDynamicStyles', 'content' => '' ) ); + echo Html::element( 'meta', [ 'name' => 'ResourceLoaderDynamicStyles', 'content' => '' ] ); ?> <?php echo "\n" . $wgOut->getHeadScripts(); ?> </head> diff --git a/TimedMediaThumbnail.php b/TimedMediaThumbnail.php index 0581617..85db7fd 100644 --- a/TimedMediaThumbnail.php +++ b/TimedMediaThumbnail.php @@ -121,9 +121,9 @@ $backend = $options['file']->getRepo()->getBackend(); // getFileHttpUrl was only added in mw 1.21, dont fail if it does not exist if ( method_exists( $backend, 'getFileHttpUrl' ) ) { - $src = $backend->getFileHttpUrl( array( + $src = $backend->getFileHttpUrl( [ 'src' => $options['file']->getPath() - ) ); + ] ); } else { $src = null; } @@ -163,8 +163,8 @@ */ static function resizeThumb( $options ) { $file = $options['file']; - $params = array(); - foreach ( array( 'start', 'thumbtime' ) as $key ) { + $params = []; + foreach ( [ 'start', 'thumbtime' ] as $key ) { if ( isset( $options[ $key ] ) ) { $params[ $key ] = $options[ $key ]; } @@ -173,15 +173,15 @@ $params["height"] = $file->getHeight(); $poolKey = $file->getRepo()->getSharedCacheKey( 'file', md5( $file->getName() ) ); - $posOptions = array_flip( array( 'start', 'thumbtime' ) ); + $posOptions = array_flip( [ 'start', 'thumbtime' ] ); $poolKey = wfAppendQuery( $poolKey, array_intersect_key( $options, $posOptions ) ); if ( class_exists( 'PoolCounterWorkViaCallback' ) ) { $work = new PoolCounterWorkViaCallback( 'TMHTransformFrame', '_tmh:frame:' . $poolKey, - array( 'doWork' => function() use ( $file, $params ) { + [ 'doWork' => function() use ( $file, $params ) { return $file->transform( $params, File::RENDER_NOW ); - } ) ); + } ] ); $thumb = $work->execute(); } else { $thumb = $file->transform( $params, File::RENDER_NOW ); @@ -196,10 +196,10 @@ } $thumbFile = new UnregisteredLocalFile( $file->getTitle(), RepoGroup::singleton()->getLocalRepo(), $src, false ); - $thumbParams = array( + $thumbParams = [ "width" => $options['width'], "height" => $options['height'] - ); + ]; $handler = $thumbFile->getHandler(); if ( !$handler ) { return false; diff --git a/TimedMediaTransformOutput.php b/TimedMediaTransformOutput.php index ed86c4c..8365e0a 100644 --- a/TimedMediaTransformOutput.php +++ b/TimedMediaTransformOutput.php @@ -19,9 +19,9 @@ const PLAYER_ID_PREFIX = 'mwe_player_'; function __construct( $conf ) { - $options = array( 'file', 'dstPath', 'sources', 'thumbUrl', 'start', 'end', + $options = [ 'file', 'dstPath', 'sources', 'thumbUrl', 'start', 'end', 'width', 'height', 'length', 'offset', 'isVideo', 'path', 'fillwindow', - 'sources', 'disablecontrols' ); + 'sources', 'disablecontrols' ]; foreach ( $options as $key ) { if ( isset( $conf[ $key ] ) ) { $this->$key = $conf[$key]; @@ -122,7 +122,7 @@ * @return string * @throws Exception */ - function toHtml( $options = array() ) { + function toHtml( $options = [] ) { global $wgTmhWebPlayer; if ( count( func_get_args() ) == 2 ) { @@ -188,32 +188,32 @@ function getImagePopUp() { // pop up videos set the autoplay attribute to true: $autoPlay = true; - return Xml::tags( 'div', array( + return Xml::tags( 'div', [ 'id' => self::PLAYER_ID_PREFIX . TimedMediaTransformOutput::$serial++, 'class' => 'PopUpMediaTransform', 'style' => "width:" . $this->getPlayerWidth() . "px;", 'videopayload' => $this->getHtmlMediaTagOutput( $this->getPopupPlayerSize(), $autoPlay ), - ), - Xml::tags( 'img', array( + ], + Xml::tags( 'img', [ 'alt' => $this->file->getTitle(), 'style' => "width:" . $this->getPlayerWidth() . "px;height:" . $this->getPlayerHeight() . "px", 'src' => $this->getUrl(), - ), '' ) + ], '' ) . // For javascript disabled browsers provide a link to the asset: - Xml::tags( 'a', array( + Xml::tags( 'a', [ 'href'=> $this->file->getUrl(), 'title' => wfMessage( 'timedmedia-play-media' )->escaped(), 'target' => 'new' - ), - Xml::tags( 'span', array( + ], + Xml::tags( 'span', [ 'class' => 'play-btn-large' - ), + ], // Have some sort of text for lynx & screen readers. Html::element( 'span', - array( 'class' => 'mw-tmh-playtext' ), + [ 'class' => 'mw-tmh-playtext' ], wfMessage( 'timedmedia-play-media' )->text() ) ) @@ -291,7 +291,7 @@ * @param $autoPlay boolean sets the autoplay attribute * @return string */ - function getHtmlMediaTagOutput( $sizeOverride = array(), $autoPlay = false ) { + function getHtmlMediaTagOutput( $sizeOverride = [], $autoPlay = false ) { global $wgTmhWebPlayer; // Try to get the first source src attribute ( usually this should be the source file ) @@ -306,12 +306,12 @@ // Sort sources by bandwidth least to greatest ( so default selection on resource constrained // browsers ( without js? ) go with minimal source. - usort( $mediaSources, array( $this, 'sortMediaByBandwidth' ) ); + usort( $mediaSources, [ $this, 'sortMediaByBandwidth' ] ); // We prefix some source attributes with data- to pass along to the javascript player - $prefixedSourceAttr = array( + $prefixedSourceAttr = [ 'width', 'height', 'title', 'shorttitle', 'bandwidth', 'framerate', 'disablecontrols' - ); + ]; foreach ( $mediaSources as &$source ) { foreach ( $source as $attr => $val ) { if ( in_array( $attr, $prefixedSourceAttr ) ) { @@ -346,10 +346,10 @@ } // else mwEmbed player // Build the video tag output: - $s = Xml::tags( 'div', array( + $s = Xml::tags( 'div', [ 'class' => 'mediaContainer', 'style' => 'width:'. $width - ), + ], Html::rawElement( $this->getTagName(), $this->getMediaAttr( $sizeOverride, $autoPlay ), // The set of media sources: self::htmlTagSet( 'source', $mediaSources ) . @@ -377,7 +377,7 @@ // Prevent potential loop throw new Exception( "Asked for poster in current size. Potential loop." ); } - $params = array( "width" => intval( $width ) ); + $params = [ "width" => intval( $width ) ]; $mto = $this->file->transform( $params ); if ( $mto ) { return $mto->getUrl(); @@ -412,7 +412,7 @@ $height .= 'px'; } - $mediaAttr = array( + $mediaAttr = [ 'id' => self::PLAYER_ID_PREFIX . TimedMediaTransformOutput::$serial++, // Get the correct size: 'poster' => $posterUrl, @@ -423,7 +423,7 @@ // Since we will reload the item with javascript, // tell browser to not load the video before 'preload'=>'none', - ); + ]; if ( $autoPlay === true ) { $mediaAttr['autoplay'] = 'true'; @@ -459,11 +459,11 @@ if ( $this->file ) { // Custom data-attributes - $mediaAttr += array( + $mediaAttr += [ 'data-durationhint' => $length, 'data-startoffset' => $offset, 'data-mwtitle' => $this->file->getTitle()->getDBkey() - ); + ]; // Add api provider: if ( $this->file->isLocal() ) { diff --git a/TimedTextPage.php b/TimedTextPage.php index 75a22ed..59fc8bc 100644 --- a/TimedTextPage.php +++ b/TimedTextPage.php @@ -10,7 +10,7 @@ class TimedTextPage extends Article { // The width of the video plane: static private $videoWidth = 400; - static private $knownTimedTextExtensions = array( 'srt', 'vtt' ); + static private $knownTimedTextExtensions = [ 'srt', 'vtt' ]; public function view() { $request = $this->getContext()->getRequest(); @@ -99,12 +99,12 @@ // Get the video with with a max of 600 pixel page $out->addHTML( - xml::tags( 'table', array( 'style'=> 'border:none' ), + xml::tags( 'table', [ 'style'=> 'border:none' ], xml::tags( 'tr', null, - xml::tags( 'td', array( 'valign' => 'top', 'width' => self::$videoWidth ), + xml::tags( 'td', [ 'valign' => 'top', 'width' => self::$videoWidth ], $this->getVideoHTML( $videoTitle ) ) . - xml::tags( 'td', array( 'valign' => 'top' ), $this->getTimedTextHTML( $languageName ) ) + xml::tags( 'td', [ 'valign' => 'top' ], $this->getTimedTextHTML( $languageName ) ) ) ) ); @@ -131,17 +131,17 @@ // Look up the language name: $language = $out->getLanguage()->getCode(); - $attrs = array( 'id' => 'timedmedia-tt-input' ); + $attrs = [ 'id' => 'timedmedia-tt-input' ]; $langSelect = Xml::languageSelector( $language, false, null, $attrs, null ); $out->addHTML( - Xml::tags( 'div', array( 'style' => 'text-align:center' ), + Xml::tags( 'div', [ 'style' => 'text-align:center' ], Xml::tags( 'div', null, wfMessage( 'timedmedia-subtitle-new-desc', $lang->getCode() )->parse() ) . $langSelect[1] . Xml::tags( 'button', - array( 'id' => 'timedmedia-tt-go' ), + [ 'id' => 'timedmedia-tt-go' ], wfMessage( 'timedmedia-subtitle-new-go' )->escaped() ) ) @@ -161,9 +161,9 @@ return wfMessage( 'timedmedia-subtitle-no-video' )->escaped(); } else { $videoTransform = $file->transform( - array( + [ 'width' => self::$videoWidth - ) + ] ); return $videoTransform->toHTML(); } @@ -181,7 +181,7 @@ } return Xml::element( 'pre', - array( 'style' => 'margin-top: 0px;' ), + [ 'style' => 'margin-top: 0px;' ], $this->getContent(), false ); diff --git a/TranscodeStatusTable.php b/TranscodeStatusTable.php index fe1d0a0..37fef9d 100644 --- a/TranscodeStatusTable.php +++ b/TranscodeStatusTable.php @@ -15,15 +15,15 @@ global $wgOut; // Add transcode table css and javascript: - $wgOut->addModules( array( 'ext.tmh.transcodetable' ) ); + $wgOut->addModules( [ 'ext.tmh.transcodetable' ] ); $o = '<h2 id="transcodestatus">' . wfMessage( 'timedmedia-status-header' )->escaped() . '</h2>'; // Give the user a purge page link $o .= Linker::link( $file->getTitle(), wfMessage( 'timedmedia-update-status' )->escaped(), - array(), - array( 'action'=> 'purge' ) + [], + [ 'action'=> 'purge' ] ); $o .= self::getTranscodesTable( $file ); @@ -68,7 +68,7 @@ } uksort( $transcodeRows, function( $a, $b ) { - $formatOrder = array( 'vp9', 'vp8', 'h264', 'theora', 'opus', 'vorbis', 'aac' ); + $formatOrder = [ 'vp9', 'vp8', 'h264', 'theora', 'opus', 'vorbis', 'aac' ]; $aFormat = self::codecFromTranscodeKey( $a ); $bFormat = self::codecFromTranscodeKey( $b ); @@ -89,7 +89,7 @@ } ); $o .= Xml::openElement( 'table', - array( 'class' => 'wikitable mw-filepage-transcodestatus' ) + [ 'class' => 'wikitable mw-filepage-transcodestatus' ] ) . "\n" . '<tr>' . '<th>' . wfMessage( 'timedmedia-transcodeinfo' )->escaped() . '</th>' @@ -193,12 +193,12 @@ } // Check for error: if ( !is_null( $state['time_error'] ) ) { - $attribs = array(); + $attribs = []; if ( !is_null( $state['error'] ) ) { - $attribs = array( + $attribs = [ 'class' => 'mw-tmh-pseudo-error-link', 'data-error' => $state['error'], - ); + ]; } return Html::rawElement( 'span', $attribs, diff --git a/WebVideoTranscode/WebVideoTranscode.php b/WebVideoTranscode/WebVideoTranscode.php index 00b5eaf..010e21c 100644 --- a/WebVideoTranscode/WebVideoTranscode.php +++ b/WebVideoTranscode/WebVideoTranscode.php @@ -70,7 +70,7 @@ const ENC_AAC = 'm4a'; // Static cache of transcode state per instantiation - public static $transcodeState = array(); + public static $transcodeState = []; /** * Encoding parameters are set via firefogg encode api @@ -80,9 +80,9 @@ * * http://firefogg.org/dev/index.html */ - public static $derivativeSettings = array( + public static $derivativeSettings = [ WebVideoTranscode::ENC_OGV_160P => - array( + [ 'maxSize' => '288x160', 'videoBitrate' => '160', 'framerate' => '15', @@ -96,9 +96,9 @@ 'bufDelay' => '256', 'videoCodec' => 'theora', 'type' => 'video/ogg; codecs="theora, vorbis"', - ), + ], WebVideoTranscode::ENC_OGV_240P => - array( + [ 'maxSize' => '426x240', 'videoBitrate' => '512', 'audioQuality' => '0', @@ -111,9 +111,9 @@ 'bufDelay' => '256', 'videoCodec' => 'theora', 'type' => 'video/ogg; codecs="theora, vorbis"', - ), + ], WebVideoTranscode::ENC_OGV_360P => - array( + [ 'maxSize' => '640x360', 'videoBitrate' => '1024', 'audioQuality' => '1', @@ -126,9 +126,9 @@ 'bufDelay' => '256', 'videoCodec' => 'theora', 'type' => 'video/ogg; codecs="theora, vorbis"', - ), + ], WebVideoTranscode::ENC_OGV_480P => - array( + [ 'maxSize' => '854x480', 'videoBitrate' => '2048', 'audioQuality' => '2', @@ -141,10 +141,10 @@ 'bufDelay' => '256', 'videoCodec' => 'theora', 'type' => 'video/ogg; codecs="theora, vorbis"', - ), + ], WebVideoTranscode::ENC_OGV_720P => - array( + [ 'maxSize' => '1280x720', 'videoQuality' => 6, 'audioQuality' => 3, @@ -154,10 +154,10 @@ 'keyframeInterval' => '128', 'videoCodec' => 'theora', 'type' => 'video/ogg; codecs="theora, vorbis"', - ), + ], WebVideoTranscode::ENC_OGV_1080P => - array( + [ 'maxSize' => '1920x1080', 'videoQuality' => 6, 'audioQuality' => 3, @@ -167,11 +167,11 @@ 'keyframeInterval' => '128', 'videoCodec' => 'theora', 'type' => 'video/ogg; codecs="theora, vorbis"', - ), + ], // WebM transcode: WebVideoTranscode::ENC_WEBM_160P => - array( + [ 'maxSize' => '288x160', 'videoBitrate' => '128', 'audioQuality' => '-1', @@ -183,9 +183,9 @@ 'bufDelay' => '256', 'videoCodec' => 'vp8', 'type' => 'video/webm; codecs="vp8, vorbis"', - ), + ], WebVideoTranscode::ENC_WEBM_240P => - array( + [ 'maxSize' => '426x240', 'videoBitrate' => '256', 'audioQuality' => '-1', @@ -197,9 +197,9 @@ 'bufDelay' => '256', 'videoCodec' => 'vp8', 'type' => 'video/webm; codecs="vp8, vorbis"', - ), + ], WebVideoTranscode::ENC_WEBM_240P => - array( + [ 'maxSize' => '426x240', 'videoBitrate' => '256', 'audioQuality' => '1', @@ -210,9 +210,9 @@ 'bufDelay' => '256', 'videoCodec' => 'vp8', 'type' => 'video/webm; codecs="vp8, vorbis"', - ), + ], WebVideoTranscode::ENC_WEBM_360P => - array( + [ 'maxSize' => '640x360', 'videoBitrate' => '512', 'audioQuality' => '1', @@ -223,9 +223,9 @@ 'bufDelay' => '256', 'videoCodec' => 'vp8', 'type' => 'video/webm; codecs="vp8, vorbis"', - ), + ], WebVideoTranscode::ENC_WEBM_480P => - array( + [ 'maxSize' => '854x480', 'videoBitrate' => '1024', 'audioQuality' => '2', @@ -236,47 +236,47 @@ 'bufDelay' => '256', 'videoCodec' => 'vp8', 'type' => 'video/webm; codecs="vp8, vorbis"', - ), + ], WebVideoTranscode::ENC_WEBM_720P => - array( + [ 'maxSize' => '1280x720', 'videoBitrate' => '2048', 'audioQuality' => 3, 'noUpscaling' => 'true', 'videoCodec' => 'vp8', 'type' => 'video/webm; codecs="vp8, vorbis"', - ), + ], WebVideoTranscode::ENC_WEBM_1080P => - array( + [ 'maxSize' => '1920x1080', 'videoBitrate' => '4096', 'audioQuality' => 3, 'noUpscaling' => 'true', 'videoCodec' => 'vp8', 'type' => 'video/webm; codecs="vp8, vorbis"', - ), + ], WebVideoTranscode::ENC_WEBM_1440P => - array( + [ 'maxSize' => '2560x1440', 'videoBitrate' => '8192', 'audioQuality' => 3, 'noUpscaling' => 'true', 'videoCodec' => 'vp8', 'type' => 'video/webm; codecs="vp8, vorbis"', - ), + ], WebVideoTranscode::ENC_WEBM_2160P => - array( + [ 'maxSize' => '4096x2160', 'videoBitrate' => '16384', 'audioQuality' => 3, 'noUpscaling' => 'true', 'videoCodec' => 'vp8', 'type' => 'video/webm; codecs="vp8, vorbis"', - ), + ], // WebM VP9 transcode: WebVideoTranscode::ENC_VP9_160P => - array( + [ 'maxSize' => '288x160', 'videoBitrate' => '80', 'samplerate' => '48000', @@ -287,9 +287,9 @@ 'videoCodec' => 'vp9', 'audioCodec' => 'opus', 'type' => 'video/webm; codecs="vp9, opus"', - ), + ], WebVideoTranscode::ENC_VP9_240P => - array( + [ 'maxSize' => '426x240', 'videoBitrate' => '128', 'samplerate' => '48000', @@ -300,9 +300,9 @@ 'videoCodec' => 'vp9', 'audioCodec' => 'opus', 'type' => 'video/webm; codecs="vp9, opus"', - ), + ], WebVideoTranscode::ENC_VP9_360P => - array( + [ 'maxSize' => '640x360', 'videoBitrate' => '256', 'samplerate' => '48000', @@ -313,9 +313,9 @@ 'videoCodec' => 'vp9', 'audioCodec' => 'opus', 'type' => 'video/webm; codecs="vp9, opus"', - ), + ], WebVideoTranscode::ENC_VP9_480P => - array( + [ 'maxSize' => '854x480', 'videoBitrate' => '512', 'samplerate' => '48000', @@ -326,9 +326,9 @@ 'videoCodec' => 'vp9', 'audioCodec' => 'opus', 'type' => 'video/webm; codecs="vp9, opus"', - ), + ], WebVideoTranscode::ENC_VP9_720P => - array( + [ 'maxSize' => '1280x720', 'videoBitrate' => '1024', 'samplerate' => '48000', @@ -340,9 +340,9 @@ 'audioCodec' => 'opus', 'tileColumns' => '2', 'type' => 'video/webm; codecs="vp9, opus"', - ), + ], WebVideoTranscode::ENC_VP9_1080P => - array( + [ 'maxSize' => '1920x1080', 'videoBitrate' => '2048', 'samplerate' => '48000', @@ -354,9 +354,9 @@ 'audioCodec' => 'opus', 'tileColumns' => '4', 'type' => 'video/webm; codecs="vp9, opus"', - ), + ], WebVideoTranscode::ENC_VP9_1440P => - array( + [ 'maxSize' => '2560x1440', 'videoBitrate' => '4096', 'samplerate' => '48000', @@ -368,9 +368,9 @@ 'audioCodec' => 'opus', 'tileColumns' => '4', 'type' => 'video/webm; codecs="vp9, opus"', - ), + ], WebVideoTranscode::ENC_VP9_2160P => - array( + [ 'maxSize' => '4096x2160', 'videoBitrate' => '8192', 'samplerate' => '48000', @@ -382,7 +382,7 @@ 'audioCodec' => 'opus', 'tileColumns' => '4', 'type' => 'video/webm; codecs="vp9, opus"', - ), + ], // @codingStandardsIgnoreStart // Losly defined per PCF guide to mp4 profiles: @@ -392,7 +392,7 @@ // @codingStandardsIgnoreEnd WebVideoTranscode::ENC_H264_160P => - array( + [ 'maxSize' => '288x160', 'videoCodec' => 'h264', 'videoBitrate' => '160k', @@ -400,10 +400,10 @@ 'channels' => '2', 'audioBitrate' => '40k', 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', - ), + ], WebVideoTranscode::ENC_H264_240P => - array( + [ 'maxSize' => '426x240', 'videoCodec' => 'h264', 'videoBitrate' => '256k', @@ -411,10 +411,10 @@ 'channels' => '2', 'audioBitrate' => '40k', 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', - ), + ], WebVideoTranscode::ENC_H264_320P => - array( + [ 'maxSize' => '480x320', 'videoCodec' => 'h264', 'videoBitrate' => '400k', @@ -422,10 +422,10 @@ 'channels' => '2', 'audioBitrate' => '40k', 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', - ), + ], WebVideoTranscode::ENC_H264_360P => - array( + [ 'maxSize' => '640x360', 'videoCodec' => 'h264', 'videoBitrate' => '512k', @@ -433,10 +433,10 @@ 'channels' => '2', 'audioBitrate' => '64k', 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', - ), + ], WebVideoTranscode::ENC_H264_480P => - array( + [ 'maxSize' => '854x480', 'videoCodec' => 'h264', 'videoBitrate' => '1200k', @@ -444,9 +444,9 @@ 'channels' => '2', 'audioBitrate' => '64k', 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', - ), + ], WebVideoTranscode::ENC_H264_720P => - array( + [ 'maxSize' => '1280x720', 'videoCodec' => 'h264', 'videoBitrate' => '2500k', @@ -454,9 +454,9 @@ 'channels' => '2', 'audioBitrate' => '128k', 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', - ), + ], WebVideoTranscode::ENC_H264_1080P => - array( + [ 'maxSize' => '1920x1080', 'videoCodec' => 'h264', 'videoBitrate' => '5000k', @@ -464,9 +464,9 @@ 'channels' => '2', 'audioBitrate' => '128k', 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', - ), + ], WebVideoTranscode::ENC_H264_1440P => - array( + [ 'maxSize' => '2560x1440', 'videoCodec' => 'h264', 'videoBitrate' => '16384k', @@ -474,9 +474,9 @@ 'channels' => '2', 'audioBitrate' => '128k', 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', - ), + ], WebVideoTranscode::ENC_H264_2160P => - array( + [ 'maxSize' => '4096x2160', 'videoCodec' => 'h264', 'videoBitrate' => '16384k', @@ -484,11 +484,11 @@ 'channels' => '2', 'audioBitrate' => '128k', 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', - ), + ], // Audio profiles WebVideoTranscode::ENC_OGG_VORBIS => - array( + [ 'audioCodec' => 'vorbis', 'audioQuality' => '3', 'samplerate' => '44100', @@ -496,9 +496,9 @@ 'noUpscaling' => 'true', 'novideo' => 'true', 'type' => 'audio/ogg; codecs="vorbis"', - ), + ], WebVideoTranscode::ENC_OGG_OPUS => - array( + [ 'audioCodec' => 'opus', 'audioQuality' => '1', 'samplerate' => '44100', @@ -506,9 +506,9 @@ 'noUpscaling' => 'true', 'novideo' => 'true', 'type' => 'audio/ogg; codecs="opus"', - ), + ], WebVideoTranscode::ENC_MP3 => - array( + [ 'audioCodec' => 'mp3', 'audioQuality' => '1', 'samplerate' => '44100', @@ -516,9 +516,9 @@ 'noUpscaling' => 'true', 'novideo' => 'true', 'type' => 'audio/mpeg', - ), + ], WebVideoTranscode::ENC_AAC => - array( + [ 'audioCodec' => 'aac', 'audioQuality' => '1', 'samplerate' => '44100', @@ -526,8 +526,8 @@ 'noUpscaling' => 'true', 'novideo' => 'true', 'type' => 'audio/mp4; codecs="mp4a.40.5"', - ), - ); + ], + ]; /** * @param $file File @@ -637,7 +637,7 @@ * @param $options array * @return array|mixed */ - public static function getSources( &$file , $options = array() ) { + public static function getSources( &$file , $options = [] ) { if ( $file->isLocal() || $file->repo instanceof ForeignDBViaLBRepo ) { return self::getLocalSources( $file, $options ); } else { @@ -656,7 +656,7 @@ * @param $options array * @return array|mixed */ - public static function getRemoteSources( &$file, $options = array() ) { + public static function getRemoteSources( &$file, $options = [] ) { global $wgMemc; // Setup source attribute options $dataPrefix = in_array( 'nodata', $options )? '': 'data-'; @@ -674,12 +674,12 @@ } wfDebug( "Get Video sources from remote api for " . $file->getName() . "\n" ); - $query = array( + $query = [ 'action' => 'query', 'prop' => 'videoinfo', 'viprop' => 'derivatives', 'titles' => MWNamespace::getCanonicalName( NS_FILE ) .':'. $file->getTitle()->getText() - ); + ]; $data = $file->repo->fetchImageQuery( $query ); @@ -688,9 +688,9 @@ ) { // Commons does not yet have TimedMediaHandler. // Use the normal file repo system single source: - return array( self::getPrimarySourceAttributes( $file, array( $dataPrefix ) ) ); + return [ self::getPrimarySourceAttributes( $file, [ $dataPrefix ] ) ]; } - $sources = array(); + $sources = []; // Generate the source list from the data response: if ( isset( $data['query'] ) && $data['query']['pages'] ) { $vidResult = array_shift( $data['query']['pages'] ); @@ -723,9 +723,9 @@ * 'nodata' Strips the data- attribute, useful when your output is not html * @return array an associative array of sources suitable for <source> tag output */ - public static function getLocalSources( &$file , $options=array() ) { + public static function getLocalSources( &$file , $options=[] ) { global $wgEnabledTranscodeSet, $wgEnabledAudioTranscodeSet, $wgEnableTranscode; - $sources = array(); + $sources = []; // Add the original file: $sources[] = self::getPrimarySourceAttributes( $file, $options ); @@ -785,7 +785,7 @@ if ( $fileName ) { unset( self::$transcodeState[ $fileName ] ); } else { - self::$transcodeState = array(); + self::$transcodeState = []; } } @@ -803,19 +803,19 @@ $db = $file->repo->getSlaveDB(); } // initialize the transcode state array - self::$transcodeState[ $fileName ] = array(); + self::$transcodeState[ $fileName ] = []; $res = $db->select( 'transcode', '*', - array( 'transcode_image_name' => $fileName ), + [ 'transcode_image_name' => $fileName ], __METHOD__, - array( 'LIMIT' => 100 ) + [ 'LIMIT' => 100 ] ); - $overTimeout = array(); + $overTimeout = []; $over = $db->timestamp( time() - ( 2 * $wgTranscodeBackgroundTimeLimit ) ); // Populate the per transcode state cache foreach ( $res as $row ) { // strip the out the "transcode_" from keys - $transcodeState = array(); + $transcodeState = []; foreach ( $row as $k => $v ) { $transcodeState[ str_replace( 'transcode_', '', $k ) ] = $v; } @@ -831,16 +831,16 @@ $dbw = wfGetDB( DB_MASTER ); $dbw->update( 'transcode', - array( + [ 'transcode_time_error' => $dbw->timestamp(), 'transcode_error' => 'timeout' - ), - array( + ], + [ 'transcode_image_name' => $fileName, 'transcode_key' => $overTimeout - ), + ], __METHOD__, - array( 'LIMIT' => count( $overTimeout ) ) + [ 'LIMIT' => count( $overTimeout ) ] ); } } @@ -863,21 +863,21 @@ // if transcode key is non-false, non-null: if ( $transcodeKey ) { // only remove the requested $transcodeKey - $removeKeys = array( $transcodeKey ); + $removeKeys = [ $transcodeKey ]; } else { // Remove any existing files ( regardless of their state ) $res = $file->repo->getMasterDB()->select( 'transcode', - array( 'transcode_key' ), - array( 'transcode_image_name' => $file->getName() ) + [ 'transcode_key' ], + [ 'transcode_image_name' => $file->getName() ] ); - $removeKeys = array(); + $removeKeys = []; foreach ( $res as $transcodeRow ) { $removeKeys[] = $transcodeRow->transcode_key; } } // Remove files by key: - $urlsToPurge = array(); + $urlsToPurge = []; foreach ( $removeKeys as $tKey ) { $urlsToPurge[] = self::getTranscodedUrlForFile( $file, $tKey ); $filePath = self::getDerivativeFilePath( $file, $tKey ); @@ -894,7 +894,7 @@ // Build the sql query: $dbw = wfGetDB( DB_MASTER ); - $deleteWhere = array( 'transcode_image_name' => $file->getName() ); + $deleteWhere = [ 'transcode_image_name' => $file->getName() ]; // Check if we are removing a specific transcode key if ( $transcodeKey !== false ) { $deleteWhere['transcode_key'] = $transcodeKey; @@ -923,11 +923,11 @@ $limit = 500; $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( - array( 'imagelinks', 'page' ), - array( 'page_namespace', 'page_title' ), - array( 'il_to' => $titleObj->getDBkey(), 'il_from = page_id' ), + [ 'imagelinks', 'page' ], + [ 'page_namespace', 'page_title' ], + [ 'il_to' => $titleObj->getDBkey(), 'il_from = page_id' ], __METHOD__, - array( 'LIMIT' => $limit + 1 ) + [ 'LIMIT' => $limit + 1 ] ); foreach ( $res as $page ) { $title = Title::makeTitle( $page->page_namespace, $page->page_title ); @@ -954,7 +954,7 @@ * @param $options array * @return array */ - public static function getPrimarySourceAttributes( $file, $options = array() ) { + public static function getPrimarySourceAttributes( $file, $options = [] ) { global $wgLang; $src = in_array( 'fullurl', $options )? wfExpandUrl( $file->getUrl() ) : $file->getUrl(); @@ -976,7 +976,7 @@ // Give grep a chance to find the usages: timedmedia-ogg, timedmedia-webm, // timedmedia-mp4, timedmedia-flac, timedmedia-wav - $source = array( + $source = [ 'src' => $src, 'type' => $file->getHandler()->getWebType( $file ), 'title' => $title, @@ -986,7 +986,7 @@ )->text(), "width" => intval( $file->getWidth() ), "height" => intval( $file->getHeight() ), - ); + ]; if ( $bitrate ) { $source["bandwidth"] = round( $bitrate ); @@ -1009,7 +1009,7 @@ * @param $options array * @return array */ - public static function getDerivativeSourceAttributes( $file, $transcodeKey, $options = array() ) { + public static function getDerivativeSourceAttributes( $file, $transcodeKey, $options = [] ) { $fileName = $file->getTitle()->getDbKey(); $src = self::getTranscodedUrlForFile( $file, $transcodeKey ); @@ -1028,7 +1028,7 @@ $file->getHandler()->getFramerate( $file ); // Setup the url src: $src = in_array( 'fullurl', $options ) ? wfExpandUrl( $src ) : $src; - $fields = array( + $fields = [ 'src' => $src, 'title' => wfMessage( 'timedmedia-derivative-desc-' . $transcodeKey )->text(), 'type' => self::$derivativeSettings[ $transcodeKey ][ 'type' ], @@ -1039,7 +1039,7 @@ // eventually we will define a manifest xml entry point. "width" => intval( $width ), "height" => intval( $height ), - ); + ]; // a "ready" transcode should have a bitrate: if ( isset( self::$transcodeState[$fileName] ) ) { @@ -1049,7 +1049,7 @@ } if ( !$file->getHandler()->isAudio( $file ) ) { - $fields += array( "framerate" => floatval( $framerate ) ); + $fields += [ "framerate" => floatval( $framerate ) ]; } return $fields; } @@ -1098,15 +1098,15 @@ if ( !isset( $transcodeState[ $transcodeKey ] ) ) { $db->insert( 'transcode', - array( + [ 'transcode_image_name' => $fileName, 'transcode_key' => $transcodeKey, 'transcode_time_addjob' => null, 'transcode_error' => "", 'transcode_final_bitrate' => 0 - ), + ], __METHOD__, - array( 'IGNORE' ) + [ 'IGNORE' ] ); } } @@ -1167,15 +1167,15 @@ if ( !isset( $transcodeState[ $transcodeKey ] ) ) { $db->insert( 'transcode', - array( + [ 'transcode_image_name' => $fileName, 'transcode_key' => $transcodeKey, 'transcode_time_addjob' => $db->timestamp(), 'transcode_error' => "", 'transcode_final_bitrate' => 0 - ), + ], __METHOD__, - array( 'IGNORE' ) + [ 'IGNORE' ] ); if ( !$db->affectedRows() ) { @@ -1183,10 +1183,10 @@ return; } - $job = new WebVideoTranscodeJob( $file->getTitle(), array( + $job = new WebVideoTranscodeJob( $file->getTitle(), [ 'transcodeMode' => 'derivative', 'transcodeKey' => $transcodeKey, - ) ); + ] ); if ( $job->insert() ) { // Clear the state cache ( now that we have updated the page ) @@ -1195,16 +1195,16 @@ // Adding job failed, update transcode row $db->update( 'transcode', - array( + [ 'transcode_time_error' => $db->timestamp(), 'transcode_error' => "Failed to insert Job." - ), - array( + ], + [ 'transcode_image_name' => $fileName, 'transcode_key' => $transcodeKey, - ), + ], __METHOD__, - array( 'LIMIT' => 1 ) + [ 'LIMIT' => 1 ] ); } } @@ -1223,7 +1223,7 @@ $sourceHeight = intval( $file->getHeight() ); if ( $sourceHeight === 0 ) { // Audio file - return array( 0, 0 ); + return [ 0, 0 ]; } $sourceAspect = $sourceWidth / $sourceHeight; $targetWidth = $sourceWidth; @@ -1243,7 +1243,7 @@ // some players do not like uneven frame sizes $targetWidth += $targetWidth%2; $targetHeight += $targetHeight%2; - return array( $targetWidth, $targetHeight ); + return [ $targetWidth, $targetHeight ]; } /** @@ -1299,7 +1299,7 @@ * @return array */ public static function getMaxSize( $targetMaxSize ) { - $maxSize = array(); + $maxSize = []; $targetMaxSize = explode( 'x', $targetMaxSize ); $maxSize['width'] = intval( $targetMaxSize[0] ); if ( count( $targetMaxSize ) == 1 ) { diff --git a/WebVideoTranscode/WebVideoTranscodeJob.php b/WebVideoTranscode/WebVideoTranscodeJob.php index 77eea98..78ae728 100644 --- a/WebVideoTranscode/WebVideoTranscodeJob.php +++ b/WebVideoTranscode/WebVideoTranscodeJob.php @@ -96,14 +96,14 @@ $dbw = wfGetDB( DB_MASTER ); $dbw->update( 'transcode', - array( + [ 'transcode_time_error' => $dbw->timestamp(), 'transcode_error' => $error - ), - array( + ], + [ 'transcode_image_name' => $this->getFile()->getName(), 'transcode_key' => $transcodeKey - ), + ], __METHOD__ ); $this->setLastError( $error ); @@ -154,10 +154,10 @@ // Check if we have "already started" the transcode ( possible error ) $dbStartTime = $dbw->selectField( 'transcode', 'transcode_time_startwork', - array( + [ 'transcode_image_name' => $this->getFile()->getName(), 'transcode_key' => $transcodeKey - ), + ], __METHOD__ ); if ( !is_null( $dbStartTime ) ) { @@ -170,11 +170,11 @@ $jobStartTimeCache = $dbw->timestamp(); $dbw->update( 'transcode', - array( 'transcode_time_startwork' => $jobStartTimeCache ), - array( + [ 'transcode_time_startwork' => $jobStartTimeCache ], + [ 'transcode_image_name' => $this->getFile()->getName(), 'transcode_key' => $transcodeKey - ), + ], __METHOD__ ); // Avoid contention and "server has gone away" errors as @@ -212,10 +212,10 @@ // Do a quick check to confirm the job was not restarted or removed while we were transcoding // Confirm that the in memory $jobStartTimeCache matches db start time $dbStartTime = $dbw->selectField( 'transcode', 'transcode_time_startwork', - array( + [ 'transcode_image_name' => $this->getFile()->getName(), 'transcode_key' => $transcodeKey - ) + ] ); // Check for ( hopefully rare ) issue of or job restarted while transcode in progress @@ -275,15 +275,15 @@ // Update the transcode table with success time: $dbw->update( 'transcode', - array( + [ 'transcode_error' => '', 'transcode_time_success' => $dbw->timestamp(), 'transcode_final_bitrate' => $bitrate - ), - array( + ], + [ 'transcode_image_name' => $this->getFile()->getName(), 'transcode_key' => $transcodeKey, - ), + ], __METHOD__ ); // Commit to reduce contention @@ -305,7 +305,7 @@ WebVideoTranscode::clearTranscodeCache( $this->title->getDBkey() ); $url = WebVideoTranscode::getTranscodedUrlForFile( $file, $transcodeKey ); - $update = new CdnCacheUpdate( array( $url ) ); + $update = new CdnCacheUpdate( [ $url ] ); $update->doUpdate(); if ( $status !== true ) { @@ -477,12 +477,12 @@ } // Handle crop: - $optionMap = array( + $optionMap = [ 'cropTop' => '-croptop', 'cropBottom' => '-cropbottom', 'cropLeft' => '-cropleft', 'cropRight' => '-cropright' - ); + ]; foreach ( $optionMap as $name => $cmdArg ) { if ( isset( $options[$name] ) ) { $cmd .= " $cmdArg " . wfEscapeShellArg( $options[$name] ); @@ -630,11 +630,11 @@ } if ( isset( $options['audioCodec'] ) ) { - $encoders = array( + $encoders = [ 'vorbis' => 'libvorbis', 'opus' => 'libopus', 'mp3' => 'libmp3lame', - ); + ]; if ( isset( $encoders[ $options['audioCodec'] ] ) ) { $codec = $encoders[ $options['audioCodec'] ]; } else { @@ -734,13 +734,13 @@ // Check if background tasks are enabled if ( $wgEnableNiceBackgroundTranscodeJobs === false ) { // Directly execute the shell command: - $limits = array( + $limits = [ "filesize" => $wgTranscodeBackgroundSizeLimit, "memory" => $wgTranscodeBackgroundMemoryLimit, "time" => $wgTranscodeBackgroundTimeLimit - ); - return wfShellExec( $cmd . ' 2>&1', $retval, array(), $limits, - array( 'profileMethod' => $caller ) ); + ]; + return wfShellExec( $cmd . ' 2>&1', $retval, [], $limits, + [ 'profileMethod' => $caller ] ); } $encodingLog = $this->getTargetEncodePath() . '.stdout.log'; @@ -803,13 +803,13 @@ // global $wgTranscodeBackgroundPriority; // $status = // wfShellExec( 'nice -n ' . $wgTranscodeBackgroundPriority . ' '. $cmd . ' 2>&1', $retval ); - $limits = array( + $limits = [ "filesize" => $wgTranscodeBackgroundSizeLimit, "memory" => $wgTranscodeBackgroundMemoryLimit, "time" => $wgTranscodeBackgroundTimeLimit - ); - $status = wfShellExec( $cmd . ' 2>&1', $retval, array(), $limits, - array( 'profileMethod' => $caller ) ); + ]; + $status = wfShellExec( $cmd . ' 2>&1', $retval, [], $limits, + [ 'profileMethod' => $caller ] ); // Output the status: wfSuppressWarnings(); @@ -953,7 +953,7 @@ * This lets us share a common api between firefogg and WebVideoTranscode * also see: http://firefogg.org/dev/index.html */ - public static $foggMap = array( + public static $foggMap = [ // video 'width' => "--width", 'height' => "--height", @@ -972,9 +972,9 @@ 'cropLeft' => "--cropleft", 'cropRight' => "--cropright", 'keyframeInterval'=> "--keyint", - 'denoise' => array( "--pp", "de" ), + 'denoise' => [ "--pp", "de" ], 'deinterlace' => "--deinterlace", - 'novideo' => array( "--novideo", "--no-skeleton" ), + 'novideo' => [ "--novideo", "--no-skeleton" ], 'bufDelay' => "--buf-delay", // audio 'audioQuality' => "-a", @@ -991,6 +991,6 @@ 'copyright' => "--copyright", 'license' => "--license", 'contact' => "--contact" - ); + ]; } diff --git a/composer.json b/composer.json index 083767b..262874c 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "require-dev": { "jakub-onderka/php-parallel-lint": "0.9.2", - "mediawiki/mediawiki-codesniffer": "0.5.1" + "mediawiki/mediawiki-codesniffer": "0.6.0" }, "scripts": { "test": [ diff --git a/handlers/FLACHandler/FLACHandler.php b/handlers/FLACHandler/FLACHandler.php index 9160d56..f8fd9cd 100644 --- a/handlers/FLACHandler/FLACHandler.php +++ b/handlers/FLACHandler/FLACHandler.php @@ -25,7 +25,7 @@ * @return array|bool */ function getStreamTypes( $file ) { - $streamTypes = array(); + $streamTypes = []; $metadata = $this->unpackMetadata( $file->getMetadata() ); if ( !$metadata || isset( $metadata['error'] ) ) { diff --git a/handlers/Mp4Handler/Mp4Handler.php b/handlers/Mp4Handler/Mp4Handler.php index 234a851..f9aa494 100644 --- a/handlers/Mp4Handler/Mp4Handler.php +++ b/handlers/Mp4Handler/Mp4Handler.php @@ -35,12 +35,12 @@ && isset( $metadata['video']['resolution_y'] ) ){ - return array( + return [ $metadata['video']['resolution_x'], $metadata['video']['resolution_y'] - ); + ]; } - return array( false, false ); + return [ false, false ]; } /** @@ -78,7 +78,7 @@ * @return array|bool */ function getStreamTypes( $file ) { - $streamTypes = array(); + $streamTypes = []; $metadata = self::unpackMetadata( $file->getMetadata() ); if ( !$metadata || isset( $metadata['error'] ) ) { return false; diff --git a/handlers/TextHandler/TextHandler.php b/handlers/TextHandler/TextHandler.php index 6d3e286..ba61e14 100644 --- a/handlers/TextHandler/TextHandler.php +++ b/handlers/TextHandler/TextHandler.php @@ -8,7 +8,6 @@ * TODO On "new" timedtext language save purge all pages where file exists */ - /** * Subclass ApiMain but query other db */ @@ -55,7 +54,7 @@ public function titlePartToKey( $titlePart, $defaultNamespace = NS_MAIN ) { $t = Title::newFromText( $titlePart . 'x' ); if ( !$t ) { - $this->dieUsageMsg( array( 'invalidtitle', $titlePart ) ); + $this->dieUsageMsg( [ 'invalidtitle', $titlePart ] ); } return substr( $t->getPrefixedDBkey(), 0, -1 ); } @@ -113,10 +112,10 @@ } // Get the namespace data from the image api repo: // fetchImageQuery query caches results - $data = $this->file->getRepo()->fetchImageQuery( array( + $data = $this->file->getRepo()->fetchImageQuery( [ 'meta' =>'siteinfo', 'siprop' => 'namespaces' - ) ); + ] ); if ( isset( $data['query'] ) && isset( $data['query']['namespaces'] ) ) { // get the ~last~ timed text namespace defined @@ -141,13 +140,13 @@ // No timed text namespace, don't try to look up timed text tracks return false; } - return array( + return [ 'action' => 'query', 'list' => 'allpages', 'apnamespace' => $ns, 'aplimit' => 300, 'apprefix' => $this->file->getTitle()->getDBkey() - ); + ]; } /** @@ -173,7 +172,7 @@ // Error in getting timed text namespace return empty array; if ( $query === false ) { - return array(); + return []; } $data = $this->file->getRepo()->fetchImageQuery( $query ); $textTracks = $this->getTextTracksFromData( $data ); @@ -194,7 +193,7 @@ $api = new ApiMain( $params ); $api->execute(); if ( defined( 'ApiResult::META_CONTENT' ) ) { - $data = $api->getResult()->getResultData( null, array( 'Strip' => 'all' ) ); + $data = $api->getResult()->getResultData( null, [ 'Strip' => 'all' ] ); } else { $data = $api->getResultData(); } @@ -202,7 +201,7 @@ // Get the list of language Names return $this->getTextTracksFromData( $data ); } else { - return array(); + return []; } } @@ -224,7 +223,7 @@ $api->profileOut(); if ( defined( 'ApiResult::META_CONTENT' ) ) { - $data = $module->getResult()->getResultData( null, array( 'Strip' => 'all' ) ); + $data = $module->getResult()->getResultData( null, [ 'Strip' => 'all' ] ); } else { $data = $module->getResultData(); } @@ -237,7 +236,7 @@ * @return array */ function getTextTracksFromData( $data ) { - $textTracks = array(); + $textTracks = []; $providerName = $this->file->repo->getName(); // commons is called shared in production. normalize it to wikimediacommons if ( $providerName == 'shared' ) { @@ -263,7 +262,7 @@ continue; } $namespacePrefix = "TimedText:"; - $textTracks[] = array( + $textTracks[] = [ 'kind' => 'subtitles', 'data-mwtitle' => $namespacePrefix . $subTitle->getDBkey(), 'data-mwprovider' => $providerName, @@ -276,7 +275,7 @@ 'label' => wfMessage( 'timedmedia-subtitle-language', $langNames[ $languageKey ], $languageKey )->text() - ); + ]; } } return $textTracks; @@ -294,17 +293,17 @@ function getFullURL( $pageTitle, $contentType ) { if ( $this->file->isLocal() ) { $subTitle = Title::newFromText( $pageTitle ); - return $subTitle->getFullURL( array( + return $subTitle->getFullURL( [ 'action' => 'raw', 'ctype' => $contentType - ) ); + ] ); // } elseif ( $this->file->repo instanceof ForeignDBViaLBRepo ) { } else { $query = 'title=' . wfUrlencode( $pageTitle ) . '&'; - $query .= wfArrayToCgi( array( + $query .= wfArrayToCgi( [ 'action' => 'raw', 'ctype' => $contentType - ) ); + ] ); // Note: This will return false if scriptDirUrl is not set for repo. return $this->file->repo->makeUrl( $query ); } diff --git a/handlers/WAVHandler/WAVHandler.php b/handlers/WAVHandler/WAVHandler.php index 4b798e3..c09aa44 100644 --- a/handlers/WAVHandler/WAVHandler.php +++ b/handlers/WAVHandler/WAVHandler.php @@ -39,7 +39,7 @@ * @return array|bool */ function getStreamTypes( $file ) { - $streamTypes = array(); + $streamTypes = []; $metadata = $this->unpackMetadata( $file->getMetadata() ); if ( !$metadata || isset( $metadata['error'] ) ) { diff --git a/handlers/WebMHandler/WebMHandler.php b/handlers/WebMHandler/WebMHandler.php index 696b795..61bcd50 100644 --- a/handlers/WebMHandler/WebMHandler.php +++ b/handlers/WebMHandler/WebMHandler.php @@ -32,24 +32,24 @@ return false; } - $size = array( false, false ); + $size = [ false, false ]; // display_x/display_y is only set if DisplayUnit // is pixels, otherwise display_aspect_ratio is set if ( isset( $metadata['video']['display_x'] ) && isset( $metadata['video']['display_y'] ) ){ - $size = array( + $size = [ $metadata['video']['display_x'], $metadata['video']['display_y'] - ); + ]; } elseif ( isset( $metadata['video']['resolution_x'] ) && isset( $metadata['video']['resolution_y'] ) ) { - $size = array( + $size = [ $metadata['video']['resolution_x'], $metadata['video']['resolution_y'] - ); + ]; if ( isset( $metadata['video']['crop_top'] ) ) { $size[1] -= $metadata['video']['crop_top']; } @@ -104,7 +104,7 @@ * @return array|bool */ function getStreamTypes( $file ) { - $streamTypes = array(); + $streamTypes = []; $metadata = $this->unpackMetadata( $file->getMetadata() ); if ( !$metadata || isset( $metadata['error'] ) ) { return false; diff --git a/maintenance/cleanupTranscodes.php b/maintenance/cleanupTranscodes.php index 12c75ce..212adad 100644 --- a/maintenance/cleanupTranscodes.php +++ b/maintenance/cleanupTranscodes.php @@ -21,9 +21,9 @@ global $wgEnabledTranscodeSet; if ( $this->hasOption( "all" ) ) { - $where = array(); + $where = []; } elseif ( $this->hasOption( "key" ) ) { - $where = array( 'transcode_key' => $this->getOption( 'key' ) ); + $where = [ 'transcode_key' => $this->getOption( 'key' ) ]; } else { $where = 'transcode_key NOT IN ("'. implode( '", "', $wgEnabledTranscodeSet ).'")'; } diff --git a/maintenance/moveTranscoded.php b/maintenance/moveTranscoded.php index 38270ef..2434dd4 100644 --- a/maintenance/moveTranscoded.php +++ b/maintenance/moveTranscoded.php @@ -19,7 +19,7 @@ $this->output( "Move transcoded files:\n" ); $dbr = wfGetDB( DB_SLAVE ); - $res = $dbr->select( 'transcode', '*', array(), __METHOD__ ); + $res = $dbr->select( 'transcode', '*', [], __METHOD__ ); foreach ( $res as $row ) { $title = Title::newFromText( $row->transcode_image_name, NS_FILE ); $file = wfLocalFile( $title ); diff --git a/maintenance/resetTranscodes.php b/maintenance/resetTranscodes.php index 8d2863b..4677c7d 100644 --- a/maintenance/resetTranscodes.php +++ b/maintenance/resetTranscodes.php @@ -16,10 +16,10 @@ $this->mDescription = "Reset stalled transcodes, that are no longer in the job queue."; } public function execute() { - $where = array( + $where = [ "transcode_time_startwork" => null, "transcode_time_error" => null - ); + ]; $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'transcode', '*', $where, __METHOD__ ); foreach ( $res as $row ) { @@ -27,10 +27,10 @@ // re-insert WebVideoTranscodeJob, // will only be added if not in queue // due to deduplication - $job = new WebVideoTranscodeJob( $title, array( + $job = new WebVideoTranscodeJob( $title, [ 'transcodeMode' => 'derivative', 'transcodeKey' => $row->transcode_key, - ) ); + ] ); $job->insert(); } } diff --git a/maintenance/retryTranscodes.php b/maintenance/retryTranscodes.php index abab8d5..5360c2a 100644 --- a/maintenance/retryTranscodes.php +++ b/maintenance/retryTranscodes.php @@ -26,7 +26,7 @@ return; } $dbw = wfGetDB( DB_MASTER ); - $cond = array(); + $cond = []; $cond[] = 'transcode_time_error IS NOT NULL'; if ( $this->hasOption( "key" ) ) { $cond['transcode_key'] = $this->getOption( 'key' ); @@ -37,14 +37,14 @@ } do { $res = $dbw->select( 'transcode', 'transcode_id', - $cond, __METHOD__, array( 'LIMIT' => 100 ) ); - $ids = array(); + $cond, __METHOD__, [ 'LIMIT' => 100 ] ); + $ids = []; foreach ( $res as $row ) { $ids[] = $row->transcode_id; } if ( $ids ) { $dbw->delete( 'transcode', - array( 'transcode_id' => $ids ), __METHOD__ ); + [ 'transcode_id' => $ids ], __METHOD__ ); wfWaitForSlaves(); } } while ( $ids ); diff --git a/tests/phpunit/ApiTestCaseVideoUpload.php b/tests/phpunit/ApiTestCaseVideoUpload.php index e569ed3..dba7b3a 100644 --- a/tests/phpunit/ApiTestCaseVideoUpload.php +++ b/tests/phpunit/ApiTestCaseVideoUpload.php @@ -19,10 +19,10 @@ * @return Array set of test files with associated metadata */ static function mediaFilesProvider() { - return array( - array( + return [ + [ // Double wrap the file array to match phpunit data provider conventions - array( + [ 'mime' => 'application/ogg', 'filePath' => __DIR__ . '/media/test5seconds.electricsheep.300x400.ogv', "size" => 301477, @@ -31,10 +31,10 @@ "mediatype" => "VIDEO", "bandwidth" => 452216, "framerate" => 30 - ) - ), - array( - array( + ] + ], + [ + [ 'mime' => 'video/webm', 'filePath' => __DIR__ . '/media/shuttle10seconds.1080x608.webm', "size" => 699018, @@ -43,9 +43,9 @@ "mediatype" => "VIDEO", "bandwidth" => 522142, "framerate" => 29.97 - ) - ) - ); + ] + ] + ]; } /** * Fixture -- run after every test @@ -69,20 +69,20 @@ protected function doLogin( $user = 'sysop' ) { $user = self::$users['uploader']; - $params = array( + $params = [ 'action' => 'login', 'lgname' => $user->username, 'lgpassword' => $user->password - ); + ]; list( $result, , $session ) = $this->doApiRequest( $params ); $token = $result['login']['token']; - $params = array( + $params = [ 'action' => 'login', 'lgtoken' => $token, 'lgname' => $user->username, 'lgpassword' => $user->password - ); + ]; list( $result, , $session ) = $this->doApiRequest( $params, $session ); return $session; } @@ -108,7 +108,7 @@ $this->markTestIncomplete( "Couldn't upload file!\n" ); } - $params = array( + $params = [ 'action' => 'upload', 'filename' => $fileName, 'file' => 'dummy content', @@ -116,7 +116,7 @@ 'text' => "This is the page text for $fileName", // This uploadFile function supports video tests not a test upload warnings 'ignorewarnings' => true - ); + ]; try { list( $result, , ) = $this->doApiRequestWithToken( $params, $session ); diff --git a/tests/phpunit/TestOggHandler.php b/tests/phpunit/TestOggHandler.php index 385fef9..bdcf6e7 100644 --- a/tests/phpunit/TestOggHandler.php +++ b/tests/phpunit/TestOggHandler.php @@ -25,24 +25,24 @@ } function providerGetCommonMetaArray() { - return array( - array( 'test5seconds.electricsheep.300x400.ogv', - array( - 'Software' => array( 'Lavf53.21.1' ), - 'ObjectName' => array( 'Electric Sheep' ), - 'UserComment' => array( '🐑' ) - ) - ), - array( 'doubleTag.oga', - array( - 'Artist' => array( 'Brian', 'Bawolff' ), - 'Software' => array( 'Lavf55.10.2' ) - ) - ), - array( 'broken-file.ogg', - array() - ), - ); + return [ + [ 'test5seconds.electricsheep.300x400.ogv', + [ + 'Software' => [ 'Lavf53.21.1' ], + 'ObjectName' => [ 'Electric Sheep' ], + 'UserComment' => [ '🐑' ] + ] + ], + [ 'doubleTag.oga', + [ + 'Artist' => [ 'Brian', 'Bawolff' ], + 'Software' => [ 'Lavf55.10.2' ] + ] + ], + [ 'broken-file.ogg', + [] + ], + ]; } /** @@ -56,13 +56,13 @@ } function providerGetWebType() { - return array( - array( 'test5seconds.electricsheep.300x400.ogv', 'video/ogg; codecs="theora"' ), - array( 'doubleTag.oga', 'audio/ogg; codecs="vorbis"' ), + return [ + [ 'test5seconds.electricsheep.300x400.ogv', 'video/ogg; codecs="theora"' ], + [ 'doubleTag.oga', 'audio/ogg; codecs="vorbis"' ], // XXX: This behaviour is somewhat questionable. It perhaps should be // application/ogg in this case. - array( 'broken-file.ogg', 'audio/ogg' ), - ); + [ 'broken-file.ogg', 'audio/ogg' ], + ]; } } diff --git a/tests/phpunit/TestTimedMediaHandler.php b/tests/phpunit/TestTimedMediaHandler.php index 2533e38..bc8a3b2 100644 --- a/tests/phpunit/TestTimedMediaHandler.php +++ b/tests/phpunit/TestTimedMediaHandler.php @@ -21,28 +21,28 @@ } function providerParseParamString() { - return array( - array( + return [ + [ 'mid', - array(), - ), - array( + [], + ], + [ '220px-', - array( 'width' => 220 ), - ), - array( + [ 'width' => 220 ], + ], + [ 'seek=30', - array( 'thumbtime' => 30.0 ), - ), - array( + [ 'thumbtime' => 30.0 ], + ], + [ 'seek=15.72', - array( 'thumbtime' => 15.72 ), - ), - array( + [ 'thumbtime' => 15.72 ], + ], + [ '180px-seek=15', - array( 'thumbtime' => 15, 'width' => 180 ), - ), - ); + [ 'thumbtime' => 15, 'width' => 180 ], + ], + ]; } } diff --git a/tests/phpunit/TestTimedMediaTransformOutput.php b/tests/phpunit/TestTimedMediaTransformOutput.php index 4154c0c..8b8a114 100644 --- a/tests/phpunit/TestTimedMediaTransformOutput.php +++ b/tests/phpunit/TestTimedMediaTransformOutput.php @@ -33,7 +33,7 @@ // Note this file has a width of 400px and a height of 300px $file = $this->dataFile( 'test5seconds.electricsheep.300x400.ogv', 'application/ogg' ); - $thumbnail = $file->transform( array( 'width' => $width ) ); + $thumbnail = $file->transform( [ 'width' => $width ] ); $this->assertTrue( $thumbnail && !$thumbnail->isError() ); $reflection = new ReflectionClass( $thumbnail ); @@ -46,12 +46,12 @@ } function providerIsPopUp() { - return array( - array( 400, 800, false ), - array( 300, 800, true ), - array( 300, 200, false ), - array( 300, 300, false ) - ); + return [ + [ 400, 800, false ], + [ 300, 800, true ], + [ 300, 200, false ], + [ 300, 300, false ] + ]; } /** @@ -61,20 +61,20 @@ * @dataProvider providerSortMediaByBandwidth */ function testSortMediaByBandwidth( $thumbWidth, $sources, $sortedSources ) { - $params = array( + $params = [ 'width' => $thumbWidth, 'height' => $thumbWidth * 9 / 16, 'isVideo' => true, 'fillwindow' => false, - 'file' => new FakeDimensionFile( array( 1820, 1024 ) ) - ); + 'file' => new FakeDimensionFile( [ 1820, 1024 ] ) + ]; $this->thumbObj = new TimedMediaTransformOutput( $params ); $reflection = new ReflectionClass( $this->thumbObj ); $this->sortMethod = $reflection->getMethod( 'sortMediaByBandwidth' ); $this->sortMethod->setAccessible( true ); - usort( $sources, array( $this, 'callSortMethodHelper' ) ); + usort( $sources, [ $this, 'callSortMethodHelper' ] ); $this->assertEquals( $sortedSources, $sources ); } @@ -82,62 +82,61 @@ return $this->sortMethod->invoke( $this->thumbObj, $a, $b ); } - function providerSortMediaByBandwidth() { - return array( - array( + return [ + [ 600, - array( - array( 'width' => 1000, 'bandwidth' => 2000 ), - array( 'width' => 1000, 'bandwidth' => 7000 ), - array( 'width' => 1000, 'bandwidth' => 1000 ), - ), - array( - array( 'width' => 1000, 'bandwidth' => 1000 ), - array( 'width' => 1000, 'bandwidth' => 2000 ), - array( 'width' => 1000, 'bandwidth' => 7000 ), - ), - ), - array( + [ + [ 'width' => 1000, 'bandwidth' => 2000 ], + [ 'width' => 1000, 'bandwidth' => 7000 ], + [ 'width' => 1000, 'bandwidth' => 1000 ], + ], + [ + [ 'width' => 1000, 'bandwidth' => 1000 ], + [ 'width' => 1000, 'bandwidth' => 2000 ], + [ 'width' => 1000, 'bandwidth' => 7000 ], + ], + ], + [ 600, - array( - array( 'width' => 200, 'bandwidth' => 2000 ), - array( 'width' => 1000, 'bandwidth' => 7000 ), - array( 'width' => 200, 'bandwidth' => 1000 ), - ), - array( - array( 'width' => 1000, 'bandwidth' => 7000 ), - array( 'width' => 200, 'bandwidth' => 1000 ), - array( 'width' => 200, 'bandwidth' => 2000 ), - ), - ), - array( + [ + [ 'width' => 200, 'bandwidth' => 2000 ], + [ 'width' => 1000, 'bandwidth' => 7000 ], + [ 'width' => 200, 'bandwidth' => 1000 ], + ], + [ + [ 'width' => 1000, 'bandwidth' => 7000 ], + [ 'width' => 200, 'bandwidth' => 1000 ], + [ 'width' => 200, 'bandwidth' => 2000 ], + ], + ], + [ /* Pop up viewer in this case */ 100, - array( - array( 'width' => 700, 'bandwidth' => 2000 ), - array( 'width' => 1000, 'bandwidth' => 7000 ), - array( 'width' => 700, 'bandwidth' => 1000 ), - ), - array( - array( 'width' => 1000, 'bandwidth' => 7000 ), - array( 'width' => 700, 'bandwidth' => 1000 ), - array( 'width' => 700, 'bandwidth' => 2000 ), - ), - ), - array( + [ + [ 'width' => 700, 'bandwidth' => 2000 ], + [ 'width' => 1000, 'bandwidth' => 7000 ], + [ 'width' => 700, 'bandwidth' => 1000 ], + ], + [ + [ 'width' => 1000, 'bandwidth' => 7000 ], + [ 'width' => 700, 'bandwidth' => 1000 ], + [ 'width' => 700, 'bandwidth' => 2000 ], + ], + ], + [ 600, - array( - array( 'width' => 700, 'bandwidth' => 2000 ), - array( 'width' => 800, 'bandwidth' => 7000 ), - array( 'width' => 1000, 'bandwidth' => 1000 ), - ), - array( - array( 'width' => 1000, 'bandwidth' => 1000 ), - array( 'width' => 700, 'bandwidth' => 2000 ), - array( 'width' => 800, 'bandwidth' => 7000 ), - ), - ), - ); + [ + [ 'width' => 700, 'bandwidth' => 2000 ], + [ 'width' => 800, 'bandwidth' => 7000 ], + [ 'width' => 1000, 'bandwidth' => 1000 ], + ], + [ + [ 'width' => 1000, 'bandwidth' => 1000 ], + [ 'width' => 700, 'bandwidth' => 2000 ], + [ 'width' => 800, 'bandwidth' => 7000 ], + ], + ], + ]; } } diff --git a/tests/phpunit/TestVideoThumbnail.php b/tests/phpunit/TestVideoThumbnail.php index a94131b..f3cfea4 100644 --- a/tests/phpunit/TestVideoThumbnail.php +++ b/tests/phpunit/TestVideoThumbnail.php @@ -19,18 +19,18 @@ // Do a API request and check for valid thumbnails: $fileName = basename( $file['filePath'] ); - $params = array( + $params = [ 'action' => 'query', 'titles' => 'File:' . $fileName, 'prop' => 'imageinfo', 'iiprop' => "url|size|thumbmime", - ); + ]; // Do a request for a small ( 200px ) thumbnail list( $result,, ) = $this->doApiRequest( - array_merge( $params, array( + array_merge( $params, [ 'iiurlwidth' => '200' - ) + ] ) ); @@ -62,10 +62,10 @@ // Test a larger thumbnail with 1 second time offset list( $result,, ) = $this->doApiRequest( - array_merge( $params, array( + array_merge( $params, [ 'iiurlwidth' => '600', 'iiurlparam' => '1' - ) + ] ) ); $page = current( $result['query']['pages'] ); diff --git a/tests/phpunit/TestVideoTranscode.php b/tests/phpunit/TestVideoTranscode.php index 72faafd..2571547 100644 --- a/tests/phpunit/TestVideoTranscode.php +++ b/tests/phpunit/TestVideoTranscode.php @@ -21,12 +21,12 @@ // Check for derivatives ( should trigger adding jobs ) $fileName = basename( $file['filePath'] ); - $params = array( + $params = [ 'action' => 'query', 'titles' => 'File:' . $fileName, 'prop' => 'videoinfo', 'viprop' => "derivatives", - ); + ]; list( $result,, ) = $this->doApiRequest( $params ); // Get the $derivatives: @@ -40,12 +40,12 @@ // Check if the transcode jobs were added: // get results: query jobs table $db = wfGetDB( DB_MASTER ); - $res = $db->select( 'transcode', '*', array( + $res = $db->select( 'transcode', '*', [ 'transcode_image_name' => ucfirst( $fileName ) - ) ); + ] ); // Make sure we target at least one ogg and one webm: $hasOgg = $hasWebM = false; - $targetEncodes = array(); + $targetEncodes = []; foreach ( $res as $row ) { $codec = WebVideoTranscode::$derivativeSettings[ $row->transcode_key ]['videoCodec']; if ( $codec == 'theora' ) { @@ -65,9 +65,9 @@ // Now run the transcode job queue $this->runTranscodeJobs(); - $res = $db->select( 'transcode', '*', array( + $res = $db->select( 'transcode', '*', [ 'transcode_image_name' => ucfirst( $fileName ) - ) ); + ] ); // Now check if the derivatives were created: list( $result,, ) = $this->doApiRequest( $params ); @@ -93,7 +93,7 @@ $dbw = wfGetDB( DB_MASTER ); $type = 'webVideoTranscode'; // Set the condition to only run the webVideoTranscode - $conds = array( "job_cmd" => $type ); + $conds = [ "job_cmd" => $type ]; while ( $dbw->selectField( 'job', 'job_id', $conds, 'runJobs.php' ) ) { diff --git a/tests/phpunit/TestWebMHandler.php b/tests/phpunit/TestWebMHandler.php index a7989e8..855ce04 100644 --- a/tests/phpunit/TestWebMHandler.php +++ b/tests/phpunit/TestWebMHandler.php @@ -25,11 +25,11 @@ } function providerGetStreamTypes() { - return array( - array( 'shuttle10seconds.1080x608.webm', array( 'VP8' ) ), - array( 'VP9-tractor.webm', array( 'VP9' ) ), - array( 'bear-vp9-opus.webm', array( 'VP9', 'Opus' ) ) - ); + return [ + [ 'shuttle10seconds.1080x608.webm', [ 'VP8' ] ], + [ 'VP9-tractor.webm', [ 'VP9' ] ], + [ 'bear-vp9-opus.webm', [ 'VP9', 'Opus' ] ] + ]; } /** @@ -43,10 +43,10 @@ } function providerGetWebType() { - return array( - array( 'shuttle10seconds.1080x608.webm', 'video/webm; codecs="vp8"' ), - array( 'VP9-tractor.webm', 'video/webm; codecs="vp9"' ), - array( 'bear-vp9-opus.webm', 'video/webm; codecs="vp9, opus"' ) - ); + return [ + [ 'shuttle10seconds.1080x608.webm', 'video/webm; codecs="vp8"' ], + [ 'VP9-tractor.webm', 'video/webm; codecs="vp9"' ], + [ 'bear-vp9-opus.webm', 'video/webm; codecs="vp9, opus"' ] + ]; } } -- To view, visit https://gerrit.wikimedia.org/r/284929 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I221b5fe3c214cbc61f2f8d413883c5f280e1b84a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TimedMediaHandler Gerrit-Branch: master Gerrit-Owner: TheDJ <hartman.w...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits