r81950 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81949‎ | r81950 | r81951 >
Date:10:01, 11 February 2011
Author:demon
Status:deferred (Comments)
Tags:
Comment:
Fix getStreamTypes(): initialized to a string but used as an array. Also remove unnecessary array_keys().
Modified paths:
  • /trunk/extensions/OggHandler/OggHandler_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OggHandler/OggHandler_body.php
@@ -338,15 +338,15 @@
339339 }
340340
341341 function getStreamTypes( $file ) {
342 - $streamTypes = '';
 342+ $streamTypes = array();
343343 $metadata = $this->unpackMetadata( $file->getMetadata() );
344344 if ( !$metadata || isset( $metadata['error'] ) ) {
345345 return false;
346346 }
347347 foreach ( $metadata['streams'] as $stream ) {
348 - $streamTypes[$stream['type']] = true;
 348+ $streamTypes[] = $stream['type'];
349349 }
350 - return array_keys( $streamTypes );
 350+ return $streamTypes;
351351 }
352352
353353 function getShortDesc( $file ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r81952Followup r81950: array_keys() had a purpose: to remove dupes. Use array_uniqu...demon10:11, 11 February 2011
r87925Forwardport r75680 and r81950 from OggHandler to TimedMediaHandlerhartman19:56, 12 May 2011

Comments

#Comment by Tim Starling (talk | contribs)   10:09, 11 February 2011

The reason for the array_keys() is to remove duplicates. You don't want the types to be array('vorbis', 'vorbis', 'vorbis'). array_unique() could have been used, but I thought this way was just as nice.

Status & tagging log