r108253 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108252‎ | r108253 | r108254 >
Date:16:58, 6 January 2012
Author:demon
Status:ok (Comments)
Tags:
Comment:
Follow up r108248, r108141: use wfUnpack() so we don't duplicate logic. Could also pass $length for sanity, but someone else can do that
Modified paths:
  • /trunk/phase3/includes/media/XCF.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/media/XCF.php
@@ -78,18 +78,16 @@
7979 # 1: Grayscale
8080 # 2: Indexed color
8181 # (enum GimpImageBaseType in libgimpbase/gimpbaseenums.h)
82 - wfSuppressWarnings();
83 - $header = unpack(
84 - "A9magic" # A: space padded
85 - . "/a5version" # a: zero padded
86 - . "/Nwidth" # \
87 - . "/Nheight" # N: unsigned long 32bit big endian
88 - . "/Nbase_type" # /
89 - , $binaryHeader
90 - );
91 - wfRestoreWarnings();
92 -
93 - if( $header === false ) {
 82+ try {
 83+ $header = wfUnpack(
 84+ "A9magic" # A: space padded
 85+ . "/a5version" # a: zero padded
 86+ . "/Nwidth" # \
 87+ . "/Nheight" # N: unsigned long 32bit big endian
 88+ . "/Nbase_type" # /
 89+ , $binaryHeader
 90+ );
 91+ } catch( MWException $mwe ) {
9492 return false;
9593 }
9694

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r108141rewrite getXCFMetaData() to get ride of im identify...hashar14:48, 5 January 2012
r108248XCF: suppress warning on unpack + early exit on error...hashar16:17, 6 January 2012

Comments

#Comment by Hashar (talk | contribs)   23:13, 6 January 2012

Of course! I was wondering how to handle the exception thrown by wfUnpack(). Guess returning false is fine.

Thanks!

Status & tagging log