From 370101602ce455a294c7dde4a714fd17ded3309e Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Thu, 5 Dec 2013 12:33:18 +0100 Subject: [PATCH] Break long lines in media related classes Change-Id: I94653b4cde14f75180dae795d1fdaa1b073ec1d1 --- includes/media/Bitmap.php | 15 +++-- includes/media/BitmapMetadataHandler.php | 4 +- includes/media/DjVuImage.php | 21 ++++-- includes/media/Exif.php | 81 ++++++++++++++++++------ includes/media/FormatMetadata.php | 28 ++++++-- includes/media/ImageHandler.php | 9 ++- includes/media/Jpeg.php | 3 +- includes/media/JpegMetadataExtractor.php | 3 +- includes/media/MediaTransformOutput.php | 5 +- includes/media/SVGMetadataExtractor.php | 17 +++-- includes/media/XCF.php | 6 +- includes/media/XMP.php | 30 +++++---- includes/media/XMPInfo.php | 19 ++++-- 13 files changed, 172 insertions(+), 69 deletions(-) diff --git a/includes/media/Bitmap.php b/includes/media/Bitmap.php index f50c3e5962..6f7130d456 100644 --- a/includes/media/Bitmap.php +++ b/includes/media/Bitmap.php @@ -57,7 +57,11 @@ class BitmapHandler extends ImageHandler { # Check if the file is smaller than the maximum image area for thumbnailing $checkImageAreaHookResult = null; - wfRunHooks( 'BitmapHandlerCheckImageArea', array( $image, &$params, &$checkImageAreaHookResult ) ); + wfRunHooks( + 'BitmapHandlerCheckImageArea', + array( $image, &$params, &$checkImageAreaHookResult ) + ); + if ( is_null( $checkImageAreaHookResult ) ) { global $wgMaxImageArea; @@ -137,7 +141,8 @@ class BitmapHandler extends ImageHandler { # Determine scaler type $scaler = self::getScalerType( $dstPath ); - wfDebug( __METHOD__ . ": creating {$scalerParams['physicalDimensions']} thumbnail at $dstPath using scaler $scaler\n" ); + wfDebug( __METHOD__ . ": creating {$scalerParams['physicalDimensions']} " . + "thumbnail at $dstPath using scaler $scaler\n" ); if ( !$image->mustRender() && $scalerParams['physicalWidth'] == $scalerParams['srcWidth'] @@ -168,7 +173,8 @@ class BitmapHandler extends ImageHandler { # Try to make a target path for the thumbnail if ( !wfMkdirParents( dirname( $dstPath ), null, __METHOD__ ) ) { - wfDebug( __METHOD__ . ": Unable to create thumbnail destination directory, falling back to client scaling\n" ); + wfDebug( __METHOD__ . ": Unable to create thumbnail destination " . + "directory, falling back to client scaling\n" ); return $this->getClientScalingThumbnailImage( $image, $scalerParams ); } @@ -530,7 +536,8 @@ class BitmapHandler extends ImageHandler { $typemap = array( 'image/gif' => array( 'imagecreatefromgif', 'palette', 'imagegif' ), - 'image/jpeg' => array( 'imagecreatefromjpeg', 'truecolor', array( __CLASS__, 'imageJpegWrapper' ) ), + 'image/jpeg' => array( 'imagecreatefromjpeg', 'truecolor', + array( __CLASS__, 'imageJpegWrapper' ) ), 'image/png' => array( 'imagecreatefrompng', 'bits', 'imagepng' ), 'image/vnd.wap.wbmp' => array( 'imagecreatefromwbmp', 'palette', 'imagewbmp' ), 'image/xbm' => array( 'imagecreatefromxbm', 'palette', 'imagexbm' ), diff --git a/includes/media/BitmapMetadataHandler.php b/includes/media/BitmapMetadataHandler.php index f85f15e50a..1e9419bf0f 100644 --- a/includes/media/BitmapMetadataHandler.php +++ b/includes/media/BitmapMetadataHandler.php @@ -197,7 +197,9 @@ class BitmapMetadataHandler { $meta = new self(); $array = PNGMetadataExtractor::getMetadata( $filename ); - if ( isset( $array['text']['xmp']['x-default'] ) && $array['text']['xmp']['x-default'] !== '' && $showXMP ) { + if ( isset( $array['text']['xmp']['x-default'] ) + && $array['text']['xmp']['x-default'] !== '' && $showXMP + ) { $xmp = new XMPReader(); $xmp->parse( $array['text']['xmp']['x-default'] ); $xmpRes = $xmp->getResults(); diff --git a/includes/media/DjVuImage.php b/includes/media/DjVuImage.php index f201c28ab8..9bfc378d08 100644 --- a/includes/media/DjVuImage.php +++ b/includes/media/DjVuImage.php @@ -84,7 +84,8 @@ class DjVuImage { function dump() { $file = fopen( $this->mFilename, 'rb' ); $header = fread( $file, 12 ); - // @todo FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables. + // @todo FIXME: Would be good to replace this extract() call with + // something that explicitly initializes local variables. extract( unpack( 'a4magic/a4chunk/NchunkLength', $header ) ); echo "$chunk $chunkLength\n"; $this->dumpForm( $file, $chunkLength, 1 ); @@ -100,7 +101,8 @@ class DjVuImage { if ( $chunkHeader == '' ) { break; } - // @todo FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables. + // @todo FIXME: Would be good to replace this extract() call with + // something that explicitly initializes local variables. extract( unpack( 'a4chunk/NchunkLength', $chunkHeader ) ); echo str_repeat( ' ', $indent * 4 ) . "$chunk $chunkLength\n"; @@ -132,7 +134,8 @@ class DjVuImage { if ( strlen( $header ) < 16 ) { wfDebug( __METHOD__ . ": too short file header\n" ); } else { - // @todo FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables. + // @todo FIXME: Would be good to replace this extract() call with + // something that explicitly initializes local variables. extract( unpack( 'a4magic/a4form/NformLength/a4subtype', $header ) ); if ( $magic != 'AT&T' ) { @@ -157,7 +160,8 @@ class DjVuImage { if ( strlen( $header ) < 8 ) { return array( false, 0 ); } else { - // @todo FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables. + // @todo FIXME: Would be good to replace this extract() call with + // something that explicitly initializes local variables. extract( unpack( 'a4chunk/Nlength', $header ) ); return array( $chunk, $length ); @@ -222,7 +226,8 @@ class DjVuImage { return false; } - // @todo FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables. + // @todo FIXME: Would be good to replace this extract() call with + // something that explicitly initializes local variables. extract( unpack( 'nwidth/' . 'nheight/' . @@ -381,7 +386,11 @@ EOT; break; } - if ( preg_match( '/^ *INFO *\[\d*\] *DjVu *(\d+)x(\d+), *\w*, *(\d+) *dpi, *gamma=([0-9.-]+)/', $line, $m ) ) { + if ( preg_match( + '/^ *INFO *\[\d*\] *DjVu *(\d+)x(\d+), *\w*, *(\d+) *dpi, *gamma=([0-9.-]+)/', + $line, + $m + ) ) { $xml .= Xml::tags( 'OBJECT', array( diff --git a/includes/media/Exif.php b/includes/media/Exif.php index 5f40fe97f9..a0d5e954ce 100644 --- a/includes/media/Exif.php +++ b/includes/media/Exif.php @@ -30,16 +30,41 @@ * @ingroup Media */ class Exif { - const BYTE = 1; //!< An 8-bit (1-byte) unsigned integer. - const ASCII = 2; //!< An 8-bit byte containing one 7-bit ASCII code. The final byte is terminated with NULL. - const SHORT = 3; //!< A 16-bit (2-byte) unsigned integer. - const LONG = 4; //!< A 32-bit (4-byte) unsigned integer. - const RATIONAL = 5; //!< Two LONGs. The first LONG is the numerator and the second LONG expresses the denominator - const SHORT_OR_LONG = 6; //!< A 16-bit (2-byte) or 32-bit (4-byte) unsigned integer. - const UNDEFINED = 7; //!< An 8-bit byte that can take any value depending on the field definition - const SLONG = 9; //!< A 32-bit (4-byte) signed integer (2's complement notation), - const SRATIONAL = 10; //!< Two SLONGs. The first SLONG is the numerator and the second SLONG is the denominator. - const IGNORE = -1; // A fake value for things we don't want or don't support. + /** An 8-bit (1-byte) unsigned integer. */ + const BYTE = 1; + + /** An 8-bit byte containing one 7-bit ASCII code. + * The final byte is terminated with NULL. + */ + const ASCII = 2; + + /** A 16-bit (2-byte) unsigned integer. */ + const SHORT = 3; + + /** A 32-bit (4-byte) unsigned integer. */ + const LONG = 4; + + /** Two LONGs. The first LONG is the numerator and the second LONG expresses + * the denominator + */ + const RATIONAL = 5; + + /** A 16-bit (2-byte) or 32-bit (4-byte) unsigned integer. */ + const SHORT_OR_LONG = 6; + + /** An 8-bit byte that can take any value depending on the field definition */ + const UNDEFINED = 7; + + /** A 32-bit (4-byte) signed integer (2's complement notation), */ + const SLONG = 9; + + /** Two SLONGs. The first SLONG is the numerator and the second SLONG is + * the denominator. + */ + const SRATIONAL = 10; + + /** A fake value for things we don't want or don't support. */ + const IGNORE = -1; //@{ /* @var array @@ -104,7 +129,8 @@ class Exif { * Constructor * * @param string $file filename. - * @param string $byteOrder Type of byte ordering either 'BE' (Big Endian) or 'LE' (Little Endian). Default ''. + * @param string $byteOrder Type of byte ordering either 'BE' (Big Endian) + * or 'LE' (Little Endian). Default ''. * @throws MWException * @todo FIXME: The following are broke: * SubjectArea. Need to test the more obscure tags. @@ -152,7 +178,8 @@ class Exif { 'TransferFunction' => Exif::IGNORE, # Transfer function 'WhitePoint' => array( Exif::RATIONAL, 2 ), # White point chromaticity 'PrimaryChromaticities' => array( Exif::RATIONAL, 6 ), # Chromaticities of primarities - 'YCbCrCoefficients' => array( Exif::RATIONAL, 3 ), # Color space transformation matrix coefficients #p27 + # Color space transformation matrix coefficients #p27 + 'YCbCrCoefficients' => array( Exif::RATIONAL, 3 ), 'ReferenceBlackWhite' => array( Exif::RATIONAL, 6 ), # Pair of black and white reference values # Other tags @@ -302,7 +329,8 @@ class Exif { $data = exif_read_data( $this->file, 0, true ); wfRestoreWarnings(); } else { - throw new MWException( "Internal error: exif_read_data not present. \$wgShowEXIF may be incorrectly set or not checked by an extension." ); + throw new MWException( "Internal error: exif_read_data not present. " . + "\$wgShowEXIF may be incorrectly set or not checked by an extension." ); } /** * exif_read_data() will return false on invalid input, such as @@ -371,10 +399,12 @@ class Exif { $this->exifGPStoNumber( 'GPSLongitude' ); $this->exifGPStoNumber( 'GPSDestLongitude' ); - if ( isset( $this->mFilteredExifData['GPSAltitude'] ) && isset( $this->mFilteredExifData['GPSAltitudeRef'] ) ) { - - // We know altitude data is a / from the validation functions ran earlier. - // But multiplying such a string by -1 doesn't work well, so convert. + if ( isset( $this->mFilteredExifData['GPSAltitude'] ) + && isset( $this->mFilteredExifData['GPSAltitudeRef'] ) + ) { + // We know altitude data is a / from the validation + // functions ran earlier. But multiplying such a string by -1 + // doesn't work well, so convert. list( $num, $denom ) = explode( '/', $this->mFilteredExifData['GPSAltitude'] ); $this->mFilteredExifData['GPSAltitude'] = $num / $denom; @@ -420,6 +450,7 @@ class Exif { } $newVal .= ord( substr( $val, $i, 1 ) ); } + if ( $this->byteOrder === 'LE' ) { // Need to reverse the string $newVal2 = ''; @@ -520,7 +551,9 @@ class Exif { $dir =& $this->mFilteredExifData[$prop . 'Ref']; $res = false; - if ( isset( $loc ) && isset( $dir ) && ( $dir === 'N' || $dir === 'S' || $dir === 'E' || $dir === 'W' ) ) { + if ( isset( $loc ) && isset( $dir ) + && ( $dir === 'N' || $dir === 'S' || $dir === 'E' || $dir === 'W' ) + ) { list( $num, $denom ) = explode( '/', $loc[0] ); $res = $num / $denom; list( $num, $denom ) = explode( '/', $loc[1] ); @@ -693,7 +726,11 @@ class Exif { */ private function isRational( $in ) { $m = array(); - if ( !is_array( $in ) && preg_match( '/^(\d+)\/(\d+[1-9]|[1-9]\d*)$/', $in, $m ) ) { # Avoid division by zero + + # Avoid division by zero + if ( !is_array( $in ) + && preg_match( '/^(\d+)\/(\d+[1-9]|[1-9]\d*)$/', $in, $m ) + ) { return $this->isLong( $m[1] ) && $this->isLong( $m[2] ); } else { $this->debug( $in, __FUNCTION__, 'fed a non-fraction value' ); @@ -734,7 +771,11 @@ class Exif { */ private function isSrational( $in ) { $m = array(); - if ( !is_array( $in ) && preg_match( '/^(-?\d+)\/(\d+[1-9]|[1-9]\d*)$/', $in, $m ) ) { # Avoid division by zero + + # Avoid division by zero + if ( !is_array( $in ) && + preg_match( '/^(-?\d+)\/(\d+[1-9]|[1-9]\d*)$/', $in, $m ) + ) { return $this->isSlong( $m[0] ) && $this->isSlong( $m[1] ); } else { $this->debug( $in, __FUNCTION__, 'fed a non-fraction value' ); diff --git a/includes/media/FormatMetadata.php b/includes/media/FormatMetadata.php index fa0fa55e57..6bd3de25f0 100644 --- a/includes/media/FormatMetadata.php +++ b/includes/media/FormatMetadata.php @@ -43,7 +43,8 @@ * is already a large number of messages using the 'exif' prefix. * * @ingroup Media - * @since 1.23 the class extends ContextSource and various formerly-public internal methods are private + * @since 1.23 the class extends ContextSource and various formerly-public + * internal methods are private */ class FormatMetadata extends ContextSource { /** @@ -302,7 +303,10 @@ class FormatMetadata extends ContextSource { case 'DateTimeMetadata': if ( $val == '0000:00:00 00:00:00' || $val == ' : : : : ' ) { $val = $this->msg( 'exif-unknowndate' )->text(); - } elseif ( preg_match( '/^(?:\d{4}):(?:\d\d):(?:\d\d) (?:\d\d):(?:\d\d):(?:\d\d)$/D', $val ) ) { + } elseif ( preg_match( + '/^(?:\d{4}):(?:\d\d):(?:\d\d) (?:\d\d):(?:\d\d):(?:\d\d)$/D', + $val + ) ) { // Full date. $time = wfTimestamp( TS_MW, $val ); if ( $time && intval( $time ) > 0 ) { @@ -984,7 +988,9 @@ class FormatMetadata extends ContextSource { * @return String single value (in wiki-syntax). * @since 1.23 */ - public static function flattenArrayContentLang( $vals, $type = 'ul', $noHtml = false, $context = false ) { + public static function flattenArrayContentLang( $vals, $type = 'ul', + $noHtml = false, $context = false + ) { global $wgContLang; $obj = new FormatMetadata; if ( $context ) { @@ -1651,7 +1657,8 @@ class FormatMetadata extends ContextSource { // If this is a remote file accessed via an API request, we already // have remote metadata so we just ignore any local one if ( $file instanceof ForeignAPIFile ) { - // in case of error we pretend no metadata - this will get cached. Might or might not be a good idea. + // In case of error we pretend no metadata - this will get cached. + // Might or might not be a good idea. return $file->getExtendedMetadata() ?: array(); } @@ -1710,7 +1717,9 @@ class FormatMetadata extends ContextSource { * @return array [ => ['value' => ]], or [] on error * @since 1.23 */ - protected function getExtendedMetadataFromHook( File $file, array $extendedMetadata, &$maxCacheTime ) { + protected function getExtendedMetadataFromHook( File $file, array $extendedMetadata, + &$maxCacheTime + ) { wfProfileIn( __METHOD__ ); wfRunHooks( 'GetExtendedMetadata', array( @@ -1856,8 +1865,13 @@ class FormatMetadata extends ContextSource { * @since 1.23 */ protected function getPriorityLanguages() { - $priorityLanguages = Language::getFallbacksIncludingSiteLanguage( $this->getLanguage()->getCode() ); - $priorityLanguages = array_merge( (array)$this->getLanguage()->getCode(), $priorityLanguages[0], $priorityLanguages[1] ); + $priorityLanguages = + Language::getFallbacksIncludingSiteLanguage( $this->getLanguage()->getCode() ); + $priorityLanguages = array_merge( + (array)$this->getLanguage()->getCode(), + $priorityLanguages[0], + $priorityLanguages[1] + ); return $priorityLanguages; } diff --git a/includes/media/ImageHandler.php b/includes/media/ImageHandler.php index c319908ac6..eecef1d591 100644 --- a/includes/media/ImageHandler.php +++ b/includes/media/ImageHandler.php @@ -227,7 +227,8 @@ abstract class ImageHandler extends MediaHandler { function getShortDesc( $file ) { global $wgLang; $nbytes = htmlspecialchars( $wgLang->formatSize( $file->getSize() ) ); - $widthheight = wfMessage( 'widthheight' )->numParams( $file->getWidth(), $file->getHeight() )->escaped(); + $widthheight = wfMessage( 'widthheight' ) + ->numParams( $file->getWidth(), $file->getHeight() )->escaped(); return "$widthheight ($nbytes)"; } @@ -260,9 +261,11 @@ abstract class ImageHandler extends MediaHandler { function getDimensionsString( $file ) { $pages = $file->pageCount(); if ( $pages > 1 ) { - return wfMessage( 'widthheightpage' )->numParams( $file->getWidth(), $file->getHeight(), $pages )->text(); + return wfMessage( 'widthheightpage' ) + ->numParams( $file->getWidth(), $file->getHeight(), $pages )->text(); } else { - return wfMessage( 'widthheight' )->numParams( $file->getWidth(), $file->getHeight() )->text(); + return wfMessage( 'widthheight' ) + ->numParams( $file->getWidth(), $file->getHeight() )->text(); } } } diff --git a/includes/media/Jpeg.php b/includes/media/Jpeg.php index ccbd5445e8..213bee09db 100644 --- a/includes/media/Jpeg.php +++ b/includes/media/Jpeg.php @@ -42,7 +42,8 @@ class JpegHandler extends ExifBitmapHandler { return serialize( $meta ); } catch ( MWException $e ) { - // BitmapMetadataHandler throws an exception in certain exceptional cases like if file does not exist. + // BitmapMetadataHandler throws an exception in certain exceptional + // cases like if file does not exist. wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" ); /* This used to use 0 (ExifBitmapHandler::OLD_BROKEN_FILE) for the cases diff --git a/includes/media/JpegMetadataExtractor.php b/includes/media/JpegMetadataExtractor.php index 7763c6f23d..00be258933 100644 --- a/includes/media/JpegMetadataExtractor.php +++ b/includes/media/JpegMetadataExtractor.php @@ -83,7 +83,8 @@ class JpegMetadataExtractor { throw new MWException( 'Too many jpeg segments. Aborting' ); } if ( $buffer !== "\xFF" ) { - throw new MWException( "Error reading jpeg file marker. Expected 0xFF but got " . bin2hex( $buffer ) ); + throw new MWException( "Error reading jpeg file marker. " . + "Expected 0xFF but got " . bin2hex( $buffer ) ); } $buffer = fread( $fh, 1 ); diff --git a/includes/media/MediaTransformOutput.php b/includes/media/MediaTransformOutput.php index 494a495d98..fa9a7298ca 100644 --- a/includes/media/MediaTransformOutput.php +++ b/includes/media/MediaTransformOutput.php @@ -345,7 +345,10 @@ class ThumbnailImage extends MediaTransformOutput { 'title' => empty( $options['title'] ) ? $title->getFullText() : $options['title'] ); } elseif ( !empty( $options['desc-link'] ) ) { - $linkAttribs = $this->getDescLinkAttribs( empty( $options['title'] ) ? null : $options['title'], $query ); + $linkAttribs = $this->getDescLinkAttribs( + empty( $options['title'] ) ? null : $options['title'], + $query + ); } elseif ( !empty( $options['file-link'] ) ) { $linkAttribs = array( 'href' => $this->file->getURL() ); } else { diff --git a/includes/media/SVGMetadataExtractor.php b/includes/media/SVGMetadataExtractor.php index 15cf82d333..d332c3f3c1 100644 --- a/includes/media/SVGMetadataExtractor.php +++ b/includes/media/SVGMetadataExtractor.php @@ -151,7 +151,9 @@ class SVGReader { $this->debug( "$tag" ); - if ( $isSVG && $tag == 'svg' && $type == XmlReader::END_ELEMENT && $this->reader->depth <= $exitDepth ) { + if ( $isSVG && $tag == 'svg' && $type == XmlReader::END_ELEMENT + && $this->reader->depth <= $exitDepth + ) { break; } elseif ( $isSVG && $tag == 'title' ) { $this->readField( $tag, 'title' ); @@ -195,7 +197,10 @@ class SVGReader { } $keepReading = $this->reader->read(); while ( $keepReading ) { - if ( $this->reader->localName == $name && $this->reader->namespaceURI == self::NS_SVG && $this->reader->nodeType == XmlReader::END_ELEMENT ) { + if ( $this->reader->localName == $name + && $this->reader->namespaceURI == self::NS_SVG + && $this->reader->nodeType == XmlReader::END_ELEMENT + ) { break; } elseif ( $this->reader->nodeType == XmlReader::TEXT ) { $this->metadata[$metafield] = trim( $this->reader->value ); @@ -219,7 +224,9 @@ class SVGReader { if ( method_exists( $this->reader, 'readInnerXML' ) ) { $this->metadata[$metafield] = trim( $this->reader->readInnerXML() ); } else { - throw new MWException( "The PHP XMLReader extension does not come with readInnerXML() method. Your libxml is probably out of date (need 2.6.20 or later)." ); + throw new MWException( "The PHP XMLReader extension does not come " . + "with readInnerXML() method. Your libxml is probably out of " . + "date (need 2.6.20 or later)." ); } $this->reader->next(); } @@ -244,7 +251,9 @@ class SVGReader { && $this->reader->nodeType == XmlReader::END_ELEMENT ) { break; - } elseif ( $this->reader->namespaceURI == self::NS_SVG && $this->reader->nodeType == XmlReader::ELEMENT ) { + } elseif ( $this->reader->namespaceURI == + self::NS_SVG && $this->reader->nodeType == XmlReader::ELEMENT + ) { switch ( $this->reader->localName ) { case 'script': // Normally we disallow files with diff --git a/includes/media/XCF.php b/includes/media/XCF.php index abf1f362c2..9f11ca76b6 100644 --- a/includes/media/XCF.php +++ b/includes/media/XCF.php @@ -121,7 +121,8 @@ class XCFHandler extends BitmapHandler { } # TODO: we might want to check for sane values of width and height - wfDebug( __METHOD__ . ": canvas size of '$filename' is {$header['width']} x {$header['height']} px\n" ); + wfDebug( __METHOD__ . + ": canvas size of '$filename' is {$header['width']} x {$header['height']} px\n" ); # Forge a return array containing metadata information just like getimagesize() # See PHP documentation at: http://www.php.net/getimagesize @@ -136,7 +137,8 @@ class XCFHandler extends BitmapHandler { $metadata['channels'] = null; $metadata['bits'] = 8; # Always 8-bits per color - assert( '7 == count($metadata); # return array must contains 7 elements just like getimagesize() return' ); + assert( '7 == count($metadata); ' . + '# return array must contains 7 elements just like getimagesize() return' ); return $metadata; } diff --git a/includes/media/XMP.php b/includes/media/XMP.php index 36e967eabc..d60b6994d1 100644 --- a/includes/media/XMP.php +++ b/includes/media/XMP.php @@ -329,7 +329,8 @@ class XMPReader { if ( !isset( $this->results['xmp-special']['HasExtendedXMP'] ) || $this->results['xmp-special']['HasExtendedXMP'] !== $guid ) { - wfDebugLog( 'XMP', __METHOD__ . " Ignoring XMPExtended block due to wrong guid (guid= '$guid')" ); + wfDebugLog( 'XMP', __METHOD__ . + " Ignoring XMPExtended block due to wrong guid (guid= '$guid')" ); return false; } @@ -341,14 +342,16 @@ class XMPReader { return false; } - // we're not very robust here. we should accept it in the wrong order. To quote - // the xmp standard: - // "A JPEG writer should write the ExtendedXMP marker segments in order, immediately following the - // StandardXMP. However, the JPEG standard does not require preservation of marker segment order. A - // robust JPEG reader should tolerate the marker segments in any order." + // we're not very robust here. we should accept it in the wrong order. + // To quote the XMP standard: + // "A JPEG writer should write the ExtendedXMP marker segments in order, + // immediately following the StandardXMP. However, the JPEG standard + // does not require preservation of marker segment order. A robust JPEG + // reader should tolerate the marker segments in any order." // - // otoh the probability that an image will have more than 128k of metadata is rather low... - // so the probability that it will have > 128k, and be in the wrong order is very low... + // otoh the probability that an image will have more than 128k of + // metadata is rather low... so the probability that it will have + // > 128k, and be in the wrong order is very low... if ( $len['offset'] !== $this->extendedXMPOffset ) { wfDebugLog( 'XMP', __METHOD__ . 'Ignoring XMPExtended block due to wrong order. (Offset was ' @@ -494,7 +497,8 @@ class XMPReader { && !( $elm === self::NS_RDF . ' Description' && $this->mode[0] === self::MODE_STRUCT ) ) { - throw new MWException( "nesting mismatch. got a but expected a curItem[0] . '>' ); + throw new MWException( "nesting mismatch. got a but expected a curItem[0] . '>' ); } // Validate structures. @@ -796,7 +800,9 @@ class XMPReader { throw new MWException( __METHOD__ . ' Encountered where it was unexpected.' ); } else { // something else we don't recognize, like a qualifier maybe. - wfDebugLog( 'XMP', __METHOD__ . " Encountered element <$elm> where only expecting character data as value of " . $this->curItem[0] ); + wfDebugLog( 'XMP', __METHOD__ . + " Encountered element <$elm> where only expecting character data as value of " . + $this->curItem[0] ); array_unshift( $this->mode, self::MODE_IGNORE ); array_unshift( $this->curItem, $elm ); } @@ -917,7 +923,8 @@ class XMPReader { if ( $this->charContent !== false ) { // Something weird. // Should not happen in valid XMP. - throw new MWException( "tag <$tag> nested in non-whitespace characters (" . $this->charContent . ")." ); + throw new MWException( "tag <$tag> nested in non-whitespace characters (" . + $this->charContent . ")." ); } } else { array_unshift( $this->mode, self::MODE_IGNORE ); @@ -1120,7 +1127,6 @@ class XMPReader { * @throws MWException */ private function doAttribs( $attribs ) { - // first check for rdf:parseType attribute, as that can change // how the attributes are interperted. diff --git a/includes/media/XMPInfo.php b/includes/media/XMPInfo.php index 03d8505069..d57af5d20c 100644 --- a/includes/media/XMPInfo.php +++ b/includes/media/XMPInfo.php @@ -53,13 +53,18 @@ class XMPInfo { * each containing an array of tags * each tag is an array of information about the * tag, including: - * * map_group - what group (used for precedence during conflicts) - * * mode - What type of item (self::MODE_SIMPLE usually, see above for all values) - * * validate - method to validate input. Could also post-process the input. A string value is assumed to be a static method of XMPValidate. Can also take a array( 'className', 'methodName' ). - * * choices - array of potential values (format of 'value' => true ). Only used with validateClosed - * * rangeLow and rangeHigh - alternative to choices for numeric ranges. Again for validateClosed only. - * * children - for MODE_STRUCT items, allowed children. - * * structPart - Indicates that this element can only appear as a member of a structure. + * * map_group - what group (used for precedence during conflicts) + * * mode - What type of item (self::MODE_SIMPLE usually, see above + * for all values) + * * validate - method to validate input. Could also post-process the + * input. A string value is assumed to be a static method of + * XMPValidate. Can also take a array( 'className', 'methodName' ). + * * choices - array of potential values (format of 'value' => true ). + * Only used with validateClosed + * * rangeLow and rangeHigh - alternative to choices for numeric ranges. + * Again for validateClosed only. + * * children - for MODE_STRUCT items, allowed children. + * * structPart - Indicates that this element can only appear as a member of a structure. * * currently this just has a bunch of exif values as this class is only half-done */ -- 2.20.1