r95179 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95178‎ | r95179 | r95180 >
Date:21:07, 21 August 2011
Author:bawolff
Status:ok
Tags:
Comment:
Follow-up r95155 - Make PagedTiffHandler use the new method to make sure the Exif support takes endian-ness of the tiff file into account

(needed because php's exif plugin doesn't do it for us... Only affects a few obscure props)

Also while I am here - change the FormatExif call to FormatMetadata (FormatExif is deprecated).
Also remove the htmlspecialchars - it doesn't make sense at this point, the result of that method is
fed through the parser in ImagePage.php and it will screw up formatting of Exif properties that
have multiple values (are arrays) and should be displayed as a list.
Modified paths:
  • /trunk/extensions/PagedTiffHandler/PagedTiffHandler.image.php (modified) (history)
  • /trunk/extensions/PagedTiffHandler/PagedTiffHandler_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/PagedTiffHandler/PagedTiffHandler_body.php
@@ -610,9 +610,15 @@
611611 return false;
612612 }
613613 unset( $exif['MEDIAWIKI_EXIF_VERSION'] );
614 - $format = new FormatExif( $exif );
 614+ if ( class_exists( 'FormatMetadata' ) ) {
 615+ // 1.18+
 616+ $formatted = FormatMetadata::getFormattedData( $exif );
 617+ } else {
 618+ // 1.17 and earlier.
 619+ $format = new FormatExif( $exif );
615620
616 - $formatted = $format->getFormattedData();
 621+ $formatted = $format->getFormattedData();
 622+ }
617623 // Sort fields into visible and collapsed
618624 $visibleFields = $this->visibleMetadataFields();
619625 foreach ( $formatted as $name => $value ) {
@@ -621,7 +627,7 @@
622628 in_array( $tag, $visibleFields ) ? 'visible' : 'collapsed',
623629 'exif',
624630 $tag,
625 - htmlspecialchars( $value )
 631+ $value
626632 );
627633 }
628634 $meta = unserialize( $metadata );
Index: trunk/extensions/PagedTiffHandler/PagedTiffHandler.image.php
@@ -170,8 +170,14 @@
171171 $this->_meta['exif'] = $data;
172172 } elseif ( $wgShowEXIF ) {
173173 wfDebug( __METHOD__ . ": using internal Exif( {$this->mFilename} )\n" );
174 - $exif = new Exif( $this->mFilename );
175 - $data = $exif->getFilteredData();
 174+ if ( method_exists( 'BitmapMetadataHandler', 'Tiff' ) ) {
 175+ $data = BitmapMetadataHandler::Tiff( $this->mFilename );
 176+ } else {
 177+ // old method for back compat.
 178+ $exif = new Exif( $this->mFilename );
 179+ $data = $exif->getFilteredData();
 180+ }
 181+
176182 if ( $data ) {
177183 $data['MEDIAWIKI_EXIF_VERSION'] = Exif::version();
178184 $this->_meta['exif'] = $data;
@@ -493,4 +499,4 @@
494500 function hasErrors() {
495501 return !empty( $this->metadata['errors'] );
496502 }
497 -}
\ No newline at end of file
 503+}

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r95155follow-up r86169 - 2 minor issues found while writing unit tests...bawolff17:16, 21 August 2011

Status & tagging log