X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Futils%2FUIDGenerator.php;h=c23d99920c57846bb9c7bcd9bc9ebcbd94d9b272;hb=a93cf8f4eee40a448bcd99b8fe1c32dc80775b6b;hp=164615ae7893e050970c56793ec8abcd74523831;hpb=6d5edd87556bc75a7b1487d4ef10b03f68eb61ac;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/utils/UIDGenerator.php b/includes/utils/UIDGenerator.php index 164615ae78..c23d99920c 100644 --- a/includes/utils/UIDGenerator.php +++ b/includes/utils/UIDGenerator.php @@ -53,7 +53,7 @@ class UIDGenerator { } // Try to get some ID that uniquely identifies this machine (RFC 4122)... if ( !preg_match( '/^[0-9a-f]{12}$/i', $nodeId ) ) { - MediaWiki\suppressWarnings(); + Wikimedia\suppressWarnings(); if ( wfIsWindows() ) { // https://technet.microsoft.com/en-us/library/bb490913.aspx $csv = trim( wfShellExec( 'getmac /NH /FO CSV' ) ); @@ -67,7 +67,7 @@ class UIDGenerator { wfShellExec( '/sbin/ifconfig -a' ), $m ); $nodeId = isset( $m[1] ) ? str_replace( ':', '', $m[1] ) : ''; } - MediaWiki\restoreWarnings(); + Wikimedia\restoreWarnings(); if ( !preg_match( '/^[0-9a-f]{12}$/i', $nodeId ) ) { $nodeId = MWCryptRand::generateHex( 12, true ); $nodeId[1] = dechex( hexdec( $nodeId[1] ) | 0x1 ); // set multicast bit @@ -400,14 +400,14 @@ class UIDGenerator { // Write back the new counter value ftruncate( $handle, 0 ); rewind( $handle ); - fwrite( $handle, fmod( $counter, pow( 2, 48 ) ) ); // warp-around as needed + fwrite( $handle, fmod( $counter, 2 ** 48 ) ); // warp-around as needed fflush( $handle ); // Release the UID lock file flock( $handle, LOCK_UN ); } $ids = []; - $divisor = pow( 2, $bits ); + $divisor = 2 ** $bits; $currentId = floor( $counter - $count ); // pre-increment counter value for ( $i = 0; $i < $count; ++$i ) { $ids[] = fmod( ++$currentId, $divisor ); @@ -532,7 +532,7 @@ class UIDGenerator { protected function millisecondsSinceEpochBinary( array $time ) { list( $sec, $msec ) = $time; $ts = 1000 * $sec + $msec; - if ( $ts > pow( 2, 52 ) ) { + if ( $ts > 2 ** 52 ) { throw new RuntimeException( __METHOD__ . ': sorry, this function doesn\'t work after the year 144680' ); } @@ -551,7 +551,7 @@ class UIDGenerator { $offset = '122192928000000000'; if ( PHP_INT_SIZE >= 8 ) { // 64 bit integers $ts = ( 1000 * $sec + $msec ) * 10000 + (int)$offset + $delta; - $id_bin = str_pad( decbin( $ts % pow( 2, 60 ) ), 60, '0', STR_PAD_LEFT ); + $id_bin = str_pad( decbin( $ts % ( 2 ** 60 ) ), 60, '0', STR_PAD_LEFT ); } elseif ( extension_loaded( 'gmp' ) ) { $ts = gmp_add( gmp_mul( (string)$sec, '1000' ), (string)$msec ); // ms $ts = gmp_add( gmp_mul( $ts, '10000' ), $offset ); // 100ns intervals