r84963 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84962‎ | r84963 | r84964 >
Date:15:37, 29 March 2011
Author:bawolff
Status:ok
Tags:
Comment:
Minor bug, don't extract dates from XMP if they are in year 0000, as there's a 99.9999% chance it will be invalid.
Modified paths:
  • /branches/img_metadata/phase3/includes/media/XMPValidate.php (modified) (history)

Diff [purge]

Index: branches/img_metadata/phase3/includes/media/XMPValidate.php
@@ -222,6 +222,17 @@
223223 * many parts are optional, some aren't. For example if you specify
224224 * minute, you must specify hour, day, month, and year but not second or TZ.
225225 */
 226+
 227+ /*
 228+ * First of all, if year = 0000, Something is wrongish,
 229+ * so don't extract. This seems to happen when
 230+ * some programs convert between metadata formats.
 231+ */
 232+ if ( $res[1] === '0000' ) {
 233+ wfDebugLog( 'XMP', __METHOD__ . " Invalid date (year 0): $val" );
 234+ $val = null;
 235+ return;
 236+ }
226237 //if month, etc unspecified, full out as 01.
227238 $res[2] = isset( $res[2] ) ? $res[2] : '01'; //month
228239 $res[3] = isset( $res[3] ) ? $res[3] : '01'; //day

Status & tagging log