Fix XMPReader/XMPValidator for PHP 7
authorBrion Vibber <brion@pobox.com>
Fri, 9 Mar 2018 19:54:19 +0000 (11:54 -0800)
committerKrinkle <krinklemail@gmail.com>
Tue, 20 Mar 2018 03:26:00 +0000 (03:26 +0000)
Tripped up by old typos being caught in new warnings on
PHP 7.x: was checking a scalar's count when meant to
check its containing array's count, and was using a str
"\0" where a literal 0 should have been used (now considered
non-numeric).

Tested locally on 7.2

Bug: T182365
Change-Id: If79a73032d6b63cc41135ccafb6900aeb7787b02

includes/libs/xmp/XMP.php
includes/libs/xmp/XMPValidate.php

index 1955915..6a4d7c4 100644 (file)
@@ -838,7 +838,7 @@ class XMPReader implements LoggerAwareInterface {
                        return;
                }
 
-               if ( count( $this->mode[0] ) === 0 ) {
+               if ( count( $this->mode ) === 0 ) {
                        // This should never ever happen and means
                        // there is a pretty major bug in this class.
                        throw new RuntimeException( 'Encountered end element with no mode' );
index 7aec28e..9fe3e33 100644 (file)
@@ -206,7 +206,7 @@ class XMPValidate implements LoggerAwareInterface {
                        $this->logger->info( __METHOD__ . " Flash structure did not have all the required components" );
                        $val = null;
                } else {
-                       $val = ( "\0" | ( $val['Fired'] === 'True' )
+                       $val = ( 0 | ( $val['Fired'] === 'True' )
                                | ( intval( $val['Return'] ) << 1 )
                                | ( intval( $val['Mode'] ) << 3 )
                                | ( ( $val['Function'] === 'True' ) << 5 )