}
// 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' ) );
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
$counter = null; // post-increment persistent counter value
- // Use APC/eAccelerator/xcache if requested, available, and not in CLI mode;
+ // Use APC/etc if requested, available, and not in CLI mode;
// Counter values would not survive accross script instances in CLI mode.
$cache = null;
if ( ( $flags & self::QUICK_VOLATILE ) && !wfIsCLI() ) {
// 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 );
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' );
}
$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