X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Futils%2FUIDGenerator.php;h=c6d1a54dd242f13a811b890a3be661d48771811e;hb=84851a43f3ea8ea146c4d82c55fd01b9fa302347;hp=abba5a1d1d496bfc2992c7599bdf557bccc56581;hpb=9ba3fca2d8adc56787c8efc32c41424cb212e387;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/utils/UIDGenerator.php b/includes/utils/UIDGenerator.php index abba5a1d1d..c6d1a54dd2 100644 --- a/includes/utils/UIDGenerator.php +++ b/includes/utils/UIDGenerator.php @@ -21,6 +21,7 @@ * @author Aaron Schulz */ use Wikimedia\Assert\Assert; +use MediaWiki\MediaWikiServices; /** * Class for getting statistically unique IDs @@ -55,13 +56,13 @@ class UIDGenerator { if ( !preg_match( '/^[0-9a-f]{12}$/i', $nodeId ) ) { MediaWiki\suppressWarnings(); if ( wfIsWindows() ) { - // http://technet.microsoft.com/en-us/library/bb490913.aspx + // https://technet.microsoft.com/en-us/library/bb490913.aspx $csv = trim( wfShellExec( 'getmac /NH /FO CSV' ) ); $line = substr( $csv, 0, strcspn( $csv, "\n" ) ); $info = str_getcsv( $line ); $nodeId = isset( $info[0] ) ? str_replace( '-', '', $info[0] ) : ''; } elseif ( is_executable( '/sbin/ifconfig' ) ) { // Linux/BSD/Solaris/OS X - // See http://linux.die.net/man/8/ifconfig + // See https://linux.die.net/man/8/ifconfig $m = []; preg_match( '/\s([0-9a-f]{2}(:[0-9a-f]{2}){5})\s/', wfShellExec( '/sbin/ifconfig -a' ), $m ); @@ -368,7 +369,7 @@ class UIDGenerator { // Counter values would not survive accross script instances in CLI mode. $cache = null; if ( ( $flags & self::QUICK_VOLATILE ) && PHP_SAPI !== 'cli' ) { - $cache = ObjectCache::getLocalServerInstance(); + $cache = MediaWikiServices::getInstance()->getLocalServerObjectCache(); } if ( $cache ) { $counter = $cache->incrWithInit( $bucket, $cache::TTL_INDEFINITE, $count, $count ); @@ -516,7 +517,7 @@ class UIDGenerator { protected function timeWaitUntil( array $time ) { do { $ct = self::millitime(); - if ( $ct >= $time ) { // http://php.net/manual/en/language.operators.comparison.php + if ( $ct >= $time ) { // https://secure.php.net/manual/en/language.operators.comparison.php return $ct; // current timestamp is higher than $time } } while ( ( ( $time[0] - $ct[0] ) * 1000 + ( $time[1] - $ct[1] ) ) <= 10 ); @@ -553,9 +554,9 @@ class UIDGenerator { $ts = ( 1000 * $sec + $msec ) * 10000 + (int)$offset + $delta; $id_bin = str_pad( decbin( $ts % pow( 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( (string)$sec, '1000' ), (string)$msec ); // ms $ts = gmp_add( gmp_mul( $ts, '10000' ), $offset ); // 100ns intervals - $ts = gmp_add( $ts, (string) $delta ); + $ts = gmp_add( $ts, (string)$delta ); $ts = gmp_mod( $ts, gmp_pow( '2', '60' ) ); // wrap around $id_bin = str_pad( gmp_strval( $ts, 2 ), 60, '0', STR_PAD_LEFT ); } elseif ( extension_loaded( 'bcmath' ) ) {