jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/383959 )

Change subject: media: Ensure there ie enough data to extract software version
......................................................................


media: Ensure there ie enough data to extract software version

The Software EXIF / other metadata field was expected to contain
the software name followed by the version number.

There are occurences in Wikimedia production logs of errors showing
that's not always the case.

Bug: T178130
Change-Id: I4187a41b5fd8d7b5574ab50523668d8feb11bccc
---
M includes/media/FormatMetadata.php
M tests/phpunit/includes/media/FormatMetadataTest.php
2 files changed, 53 insertions(+), 2 deletions(-)

Approvals:
  Umherirrender: Looks good to me, approved
  Matthias Mullie: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/includes/media/FormatMetadata.php 
b/includes/media/FormatMetadata.php
index 6661965..b008a22 100644
--- a/includes/media/FormatMetadata.php
+++ b/includes/media/FormatMetadata.php
@@ -740,8 +740,13 @@
 
                                        case 'Software':
                                                if ( is_array( $val ) ) {
-                                                       // if its a software, 
version array.
-                                                       $val = $this->msg( 
'exif-software-version-value', $val[0], $val[1] )->text();
+                                                       if ( count( $val ) > 1 
) {
+                                                               // if its a 
software, version array.
+                                                               $val = 
$this->msg( 'exif-software-version-value', $val[0], $val[1] )->text();
+                                                       } else {
+                                                               // 
https://phabricator.wikimedia.org/T178130
+                                                               $val = 
$this->exifMsg( $tag, '', $val[0] );
+                                                       }
                                                } else {
                                                        $val = $this->exifMsg( 
$tag, '', $val );
                                                }
diff --git a/tests/phpunit/includes/media/FormatMetadataTest.php 
b/tests/phpunit/includes/media/FormatMetadataTest.php
index e9fc84e..16ae193 100644
--- a/tests/phpunit/includes/media/FormatMetadataTest.php
+++ b/tests/phpunit/includes/media/FormatMetadataTest.php
@@ -95,4 +95,50 @@
                        ],
                ];
        }
+
+       /**
+        * @param mixed $input
+        * @param mixed $output
+        * @dataProvider provideGetFormattedData
+        * @covers FormatMetadata::getFormattedData
+        */
+       public function testGetFormattedData( $input, $output ) {
+               $this->assertEquals( $output, FormatMetadata::getFormattedData( 
$input ) );
+       }
+
+       public function provideGetFormattedData() {
+               return [
+                       [
+                               [ 'Software' => 'Adobe Photoshop CS6 
(Macintosh)' ],
+                               [ 'Software' => 'Adobe Photoshop CS6 
(Macintosh)' ],
+                       ],
+                       [
+                               [ 'Software' => [ 'FotoWare FotoStation' ] ],
+                               [ 'Software' => 'FotoWare FotoStation' ],
+                       ],
+                       [
+                               [ 'Software' => [ [ 'Capture One PRO', '3.7.7' 
] ] ],
+                               [ 'Software' => 'Capture One PRO (Version 
3.7.7)' ],
+                       ],
+                       [
+                               [ 'Software' => [ [ 'FotoWare ColorFactory', '' 
] ] ],
+                               [ 'Software' => 'FotoWare ColorFactory (Version 
)' ],
+                       ],
+                       [
+                               [ 'Software' => [ 'x-default' => 'paint.net 
4.0.12', '_type' => 'lang' ] ],
+                               [ 'Software' => '<ul 
class="metadata-langlist">'.
+                                               '<li 
class="mw-metadata-lang-default">'.
+                                                       '<span 
class="mw-metadata-lang-value">paint.net 4.0.12</span>'.
+                                               "</li>\n".
+                                       '</ul>'
+                               ],
+                       ],
+                       [
+                               // https://phabricator.wikimedia.org/T178130
+                               // WebMHandler.php turns both 'muxingapp' & 
'writingapp' to 'Software'
+                               [ 'Software' => [ [ 'Lavf57.25.100' ], [ 
'Lavf57.25.100' ] ] ],
+                               [ 'Software' => 
"<ul><li>Lavf57.25.100</li>\n<li>Lavf57.25.100</li></ul>" ],
+                       ],
+               ];
+       }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/383959
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4187a41b5fd8d7b5574ab50523668d8feb11bccc
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Dereckson <dereck...@espace-win.org>
Gerrit-Reviewer: Brian Wolff <bawolff...@gmail.com>
Gerrit-Reviewer: MarkTraceur <mholmqu...@wikimedia.org>
Gerrit-Reviewer: Matthias Mullie <mmul...@wikimedia.org>
Gerrit-Reviewer: Umherirrender <umherirrender_de...@web.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to