MediaWiki REL1_37
GlobalIdGenerator.php
Go to the documentation of this file.
1<?php
22
23use InvalidArgumentException;
24use RuntimeException;
25use Wikimedia\Assert\Assert;
26use Wikimedia\AtEase\AtEase;
27use Wikimedia\Timestamp\ConvertibleTimestamp;
28
36 protected $shellCallback;
37
39 protected $tmpDir;
41 protected $nodeIdFile;
43 protected $nodeId32;
45 protected $nodeId48;
46
48 protected $loaded = false;
50 protected $lockFile88;
52 protected $lockFile128;
54 protected $lockFileUUID;
55
57 protected $fileHandles = []; // cached file handles
58
60 public const QUICK_VOLATILE = 1;
61
66 private const FILE_PREFIX = 'mw-GlobalIdGenerator';
67
69 private const CLOCK_TIME = 'time';
71 private const CLOCK_COUNTER = 'counter';
73 private const CLOCK_SEQUENCE = 'clkSeq';
75 private const CLOCK_OFFSET = 'offset';
77 private const CLOCK_OFFSET_COUNTER = 'offsetCounter';
78
83 public function __construct( $tempDirectory, $shellCallback ) {
84 if ( func_num_args() >= 3 && !is_callable( $shellCallback ) ) {
85 trigger_error(
86 __CLASS__ . ' with a BagOStuff instance was deprecated in MediaWiki 1.37.',
87 E_USER_DEPRECATED
88 );
89 $shellCallback = func_get_arg( 2 );
90 }
91 if ( !strlen( $tempDirectory ) ) {
92 throw new InvalidArgumentException( "No temp directory provided" );
93 }
94 $this->tmpDir = $tempDirectory;
95 $this->nodeIdFile = $tempDirectory . '/' . self::FILE_PREFIX . '-UID-nodeid';
96 // If different processes run as different users, they may have different temp dirs.
97 // This is dealt with by initializing the clock sequence number and counters randomly.
98 $this->lockFile88 = $tempDirectory . '/' . self::FILE_PREFIX . '-UID-88';
99 $this->lockFile128 = $tempDirectory . '/' . self::FILE_PREFIX . '-UID-128';
100 $this->lockFileUUID = $tempDirectory . '/' . self::FILE_PREFIX . '-UUID-128';
101
102 $this->shellCallback = $shellCallback;
103 }
104
120 public function newTimestampedUID88( int $base = 10 ) {
121 Assert::parameter( $base <= 36, '$base', 'must be <= 36' );
122 Assert::parameter( $base >= 2, '$base', 'must be >= 2' );
123
124 $info = $this->getTimeAndDelay( 'lockFile88', 1, 1024, 1024 );
125 $info[self::CLOCK_OFFSET_COUNTER] %= 1024;
126
127 return \Wikimedia\base_convert( $this->getTimestampedID88( $info ), 2, $base );
128 }
129
135 protected function getTimestampedID88( array $info ) {
136 $time = $info[self::CLOCK_TIME];
137 $counter = $info[self::CLOCK_OFFSET_COUNTER];
138 // Take the 46 LSBs of "milliseconds since epoch"
139 $id_bin = $this->millisecondsSinceEpochBinary( $time );
140 // Add a 10 bit counter resulting in 56 bits total
141 $id_bin .= str_pad( decbin( $counter ), 10, '0', STR_PAD_LEFT );
142 // Add the 32 bit node ID resulting in 88 bits total
143 $id_bin .= $this->getNodeId32();
144 // Convert to a 1-27 digit integer string
145 if ( strlen( $id_bin ) !== 88 ) {
146 throw new RuntimeException( "Detected overflow for millisecond timestamp." );
147 }
148
149 return $id_bin;
150 }
151
166 public function newTimestampedUID128( int $base = 10 ) {
167 Assert::parameter( $base <= 36, '$base', 'must be <= 36' );
168 Assert::parameter( $base >= 2, '$base', 'must be >= 2' );
169
170 $info = $this->getTimeAndDelay( 'lockFile128', 16384, 1048576, 1048576 );
171 $info[self::CLOCK_OFFSET_COUNTER] %= 1048576;
172
173 return \Wikimedia\base_convert( $this->getTimestampedID128( $info ), 2, $base );
174 }
175
181 protected function getTimestampedID128( array $info ) {
182 $time = $info[self::CLOCK_TIME];
183 $counter = $info[self::CLOCK_OFFSET_COUNTER];
184 $clkSeq = $info[self::CLOCK_SEQUENCE];
185 // Take the 46 LSBs of "milliseconds since epoch"
186 $id_bin = $this->millisecondsSinceEpochBinary( $time );
187 // Add a 20 bit counter resulting in 66 bits total
188 $id_bin .= str_pad( decbin( $counter ), 20, '0', STR_PAD_LEFT );
189 // Add a 14 bit clock sequence number resulting in 80 bits total
190 $id_bin .= str_pad( decbin( $clkSeq ), 14, '0', STR_PAD_LEFT );
191 // Add the 48 bit node ID resulting in 128 bits total
192 $id_bin .= $this->getNodeId48();
193 // Convert to a 1-39 digit integer string
194 if ( strlen( $id_bin ) !== 128 ) {
195 throw new RuntimeException( "Detected overflow for millisecond timestamp." );
196 }
197
198 return $id_bin;
199 }
200
207 public function newUUIDv1() {
208 // There can be up to 10000 intervals for the same millisecond timestamp.
209 // [0,4999] counter + [0,5000] offset is in [0,9999] for the offset counter.
210 // Add this onto the timestamp to allow making up to 5000 IDs per second.
211 return $this->getUUIDv1( $this->getTimeAndDelay( 'lockFileUUID', 16384, 5000, 5001 ) );
212 }
213
218 protected function getUUIDv1( array $info ) {
219 $clkSeq_bin = \Wikimedia\base_convert( $info[self::CLOCK_SEQUENCE], 10, 2, 14 );
220 $time_bin = $this->intervalsSinceGregorianBinary(
221 $info[self::CLOCK_TIME],
222 $info[self::CLOCK_OFFSET_COUNTER]
223 );
224 // Take the 32 bits of "time low"
225 $id_bin = substr( $time_bin, 28, 32 );
226 // Add 16 bits of "time mid" resulting in 48 bits total
227 $id_bin .= substr( $time_bin, 12, 16 );
228 // Add 4 bit version resulting in 52 bits total
229 $id_bin .= '0001';
230 // Add 12 bits of "time high" resulting in 64 bits total
231 $id_bin .= substr( $time_bin, 0, 12 );
232 // Add 2 bits of "variant" resulting in 66 bits total
233 $id_bin .= '10';
234 // Add 6 bits of "clock seq high" resulting in 72 bits total
235 $id_bin .= substr( $clkSeq_bin, 0, 6 );
236 // Add 8 bits of "clock seq low" resulting in 80 bits total
237 $id_bin .= substr( $clkSeq_bin, 6, 8 );
238 // Add the 48 bit node ID resulting in 128 bits total
239 $id_bin .= $this->getNodeId48();
240 // Convert to a 32 char hex string with dashes
241 if ( strlen( $id_bin ) !== 128 ) {
242 throw new RuntimeException( "Detected overflow for millisecond timestamp." );
243 }
244 $hex = \Wikimedia\base_convert( $id_bin, 2, 16, 32 );
245 return sprintf( '%s-%s-%s-%s-%s',
246 // "time_low" (32 bits)
247 substr( $hex, 0, 8 ),
248 // "time_mid" (16 bits)
249 substr( $hex, 8, 4 ),
250 // "time_hi_and_version" (16 bits)
251 substr( $hex, 12, 4 ),
252 // "clk_seq_hi_res" (8 bits) and "clk_seq_low" (8 bits)
253 substr( $hex, 16, 4 ),
254 // "node" (48 bits)
255 substr( $hex, 20, 12 )
256 );
257 }
258
265 public function newRawUUIDv1() {
266 return str_replace( '-', '', $this->newUUIDv1() );
267 }
268
275 public function newUUIDv4() {
276 $hex = bin2hex( random_bytes( 32 / 2 ) );
277
278 return sprintf( '%s-%s-%s-%s-%s',
279 // "time_low" (32 bits)
280 substr( $hex, 0, 8 ),
281 // "time_mid" (16 bits)
282 substr( $hex, 8, 4 ),
283 // "time_hi_and_version" (16 bits)
284 '4' . substr( $hex, 12, 3 ),
285 // "clk_seq_hi_res" (8 bits, variant is binary 10x) and "clk_seq_low" (8 bits)
286 dechex( 0x8 | ( hexdec( $hex[15] ) & 0x3 ) ) . $hex[16] . substr( $hex, 17, 2 ),
287 // "node" (48 bits)
288 substr( $hex, 19, 12 )
289 );
290 }
291
298 public function newRawUUIDv4() {
299 return str_replace( '-', '', $this->newUUIDv4() );
300 }
301
314 public function newSequentialPerNodeID( $bucket, $bits = 48, $flags = 0 ) {
315 return current( $this->newSequentialPerNodeIDs( $bucket, $bits, 1, $flags ) );
316 }
317
328 public function newSequentialPerNodeIDs( $bucket, $bits, $count, $flags = 0 ) {
329 return $this->getSequentialPerNodeIDs( $bucket, $bits, $count, $flags );
330 }
331
339 public function getTimestampFromUUIDv1( string $uuid, int $format = TS_MW ) {
340 $components = [];
341 if ( !preg_match(
342 '/^([0-9a-f]{8})-([0-9a-f]{4})-(1[0-9a-f]{3})-([89ab][0-9a-f]{3})-([0-9a-f]{12})$/',
343 $uuid,
344 $components
345 ) ) {
346 throw new InvalidArgumentException( "Invalid UUIDv1 {$uuid}" );
347 }
348
349 $timestamp = hexdec( substr( $components[3], 1 ) . $components[2] . $components[1] );
350 // The 60 bit timestamp value is constructed from fields of this UUID.
351 // The timestamp is measured in 100-nanosecond units since midnight, October 15, 1582 UTC.
352 $unixTime = ( $timestamp - 0x01b21dd213814000 ) / 1e7;
353
354 return ConvertibleTimestamp::convert( $format, $unixTime );
355 }
356
368 protected function getSequentialPerNodeIDs( $bucket, $bits, $count, $flags ) {
369 if ( $count <= 0 ) {
370 return []; // nothing to do
371 }
372 if ( $bits < 16 || $bits > 48 ) {
373 throw new RuntimeException( "Requested bit size ($bits) is out of range." );
374 }
375
376 $path = $this->tmpDir . '/' . self::FILE_PREFIX . '-' . rawurlencode( $bucket ) . '-48';
377 // Get the UID lock file handle
378 if ( isset( $this->fileHandles[$path] ) ) {
379 $handle = $this->fileHandles[$path];
380 } else {
381 $handle = fopen( $path, 'cb+' );
382 $this->fileHandles[$path] = $handle ?: null; // cache
383 }
384 // Acquire the UID lock file
385 if ( $handle === false ) {
386 throw new RuntimeException( "Could not open '{$path}'." );
387 }
388 if ( !flock( $handle, LOCK_EX ) ) {
389 fclose( $handle );
390 throw new RuntimeException( "Could not acquire '{$path}'." );
391 }
392 // Fetch the counter value and increment it...
393 rewind( $handle );
394 $counter = floor( (float)trim( fgets( $handle ) ) ) + $count; // fetch as float
395 // Write back the new counter value
396 ftruncate( $handle, 0 );
397 rewind( $handle );
398 // Use fmod() to avoid "division by zero" on 32 bit machines
399 fwrite( $handle, fmod( $counter, 2 ** 48 ) ); // warp-around as needed
400 fflush( $handle );
401 // Release the UID lock file
402 flock( $handle, LOCK_UN );
403
404 $ids = [];
405 $divisor = 2 ** $bits;
406 $currentId = floor( $counter - $count ); // pre-increment counter value
407 for ( $i = 0; $i < $count; ++$i ) {
408 // Use fmod() to avoid "division by zero" on 32 bit machines
409 $ids[] = fmod( ++$currentId, $divisor );
410 }
411
412 return $ids;
413 }
414
432 protected function getTimeAndDelay( $lockFile, $clockSeqSize, $counterSize, $offsetSize ) {
433 // Get the UID lock file handle
434 if ( isset( $this->fileHandles[$this->$lockFile] ) ) {
435 $handle = $this->fileHandles[$this->$lockFile];
436 } else {
437 $handle = fopen( $this->$lockFile, 'cb+' );
438 $this->fileHandles[$this->$lockFile] = $handle ?: null; // cache
439 }
440 // Acquire the UID lock file
441 if ( $handle === false ) {
442 throw new RuntimeException( "Could not open '{$this->$lockFile}'." );
443 }
444 if ( !flock( $handle, LOCK_EX ) ) {
445 fclose( $handle );
446 throw new RuntimeException( "Could not acquire '{$this->$lockFile}'." );
447 }
448
449 // The formatters that use this method expect a timestamp with millisecond
450 // precision and a counter upto a certain size. When more IDs than the counter
451 // size are generated during the same timestamp, an exception is thrown as we
452 // cannot increment further, because the formatted ID would not have enough
453 // bits to fit the counter.
454 //
455 // To orchestrate this between independent PHP processes on the same host,
456 // we must have a common sense of time so that we only have to maintain
457 // a single counter in a single lock file.
458 //
459 // Given that:
460 // * The system clock can be observed via time(), without milliseconds.
461 // * Some other clock can be observed via microtime(), which also offers
462 // millisecond precision.
463 // * microtime() drifts in-process further and further away from the system
464 // clock the longer a process runs for.
465 // For example, on 2018-10-03 an HHVM 3.18 JobQueue process at WMF,
466 // that ran for 9 min 55 sec, microtime drifted by 7 seconds.
467 // time() does not have this problem. See https://bugs.php.net/bug.php?id=42659.
468 //
469 // We have two choices:
470 //
471 // 1. Use microtime() with the following caveats:
472 // - The last stored time may be in the future, or our current time may be in the
473 // past, in which case we'll frequently enter the slow timeWaitUntil() method to
474 // try and "sync" the current process with the previous process.
475 // We mustn't block for long though, max 10ms?
476 // - For any drift above 10ms, we pretend that the clock went backwards, and treat
477 // it the same way as after an NTP sync, by incrementing clock sequence instead.
478 // Given the sequence rolls over automatically, and silently, and is meant to be
479 // rare, this is essentially sacrifices a reasonable guarantee of uniqueness.
480 // - For long running processes (e.g. longer than a few seconds) the drift can
481 // easily be more than 2 seconds. Because we only have a single lock file
482 // and don't want to keep too many counters and deal with clearing those,
483 // we fatal the user and refuse to make an ID. (T94522)
484 // - This offers terrible service availability.
485 // 2. Use time() instead, and expand the counter size by 1000x and use its
486 // digits as if they were the millisecond fraction of our timestamp.
487 // Known caveats or perf impact: None. We still need to read-write our
488 // lock file on each generation, so might as well make the most of it.
489 //
490 // We choose the latter.
491 $msecCounterSize = $counterSize * 1000;
492
493 rewind( $handle );
494 // Format of lock file contents:
495 // "<clk seq> <sec> <msec counter> <rand offset>"
496 $data = explode( ' ', fgets( $handle ) );
497
498 if ( count( $data ) === 4 ) {
499 // The UID lock file was already initialized
500 $clkSeq = (int)$data[0] % $clockSeqSize;
501 $prevSec = (int)$data[1];
502 // Counter for UIDs with the same timestamp,
503 $msecCounter = 0;
504 $randOffset = (int)$data[3] % $counterSize;
505
506 // If the system clock moved backwards by an NTP sync,
507 // or if the last writer process had its clock drift ahead,
508 // Try to catch up if the gap is small, so that we can keep a single
509 // monotonic logic file.
510 $sec = $this->timeWaitUntil( $prevSec );
511 if ( $sec === false ) {
512 // Gap is too big. Looks like the clock got moved back significantly.
513 // Start a new clock sequence, and re-randomize the extra offset,
514 // which is useful for UIDs that do not include the clock sequence number.
515 $clkSeq = ( $clkSeq + 1 ) % $clockSeqSize;
516 $sec = time();
517 $randOffset = mt_rand( 0, $offsetSize - 1 );
518 trigger_error( "Clock was set back; sequence number incremented." );
519 } elseif ( $sec === $prevSec ) {
520 // Sanity check, only keep remainder if a previous writer wrote
521 // something here that we don't accept.
522 $msecCounter = (int)$data[2] % $msecCounterSize;
523 // Bump the counter if the time has not changed yet
524 if ( ++$msecCounter >= $msecCounterSize ) {
525 // More IDs generated with the same time than counterSize can accomodate
526 flock( $handle, LOCK_UN );
527 throw new RuntimeException( "Counter overflow for timestamp value." );
528 }
529 }
530 } else {
531 // Initialize UID lock file information
532 $clkSeq = mt_rand( 0, $clockSeqSize - 1 );
533 $sec = time();
534 $msecCounter = 0;
535 $randOffset = mt_rand( 0, $offsetSize - 1 );
536 }
537
538 // Update and release the UID lock file
539 ftruncate( $handle, 0 );
540 rewind( $handle );
541 fwrite( $handle, "{$clkSeq} {$sec} {$msecCounter} {$randOffset}" );
542 fflush( $handle );
543 flock( $handle, LOCK_UN );
544
545 // Split msecCounter back into msec and counter
546 $msec = (int)( $msecCounter / 1000 );
547 $counter = $msecCounter % 1000;
548
549 return [
550 self::CLOCK_TIME => [ $sec, $msec ],
551 self::CLOCK_COUNTER => $counter,
552 self::CLOCK_SEQUENCE => $clkSeq,
553 self::CLOCK_OFFSET => $randOffset,
554 self::CLOCK_OFFSET_COUNTER => $counter + $randOffset,
555 ];
556 }
557
565 protected function timeWaitUntil( $time ) {
566 $start = microtime( true );
567 do {
568 $ct = time();
569 // https://www.php.net/manual/en/language.operators.comparison.php
570 if ( $ct >= $time ) {
571 // current time is higher than or equal to than $time
572 return $ct;
573 }
574 } while ( ( microtime( true ) - $start ) <= 0.010 ); // up to 10ms
575
576 return false;
577 }
578
584 protected function millisecondsSinceEpochBinary( array $time ) {
585 list( $sec, $msec ) = $time;
586 $ts = 1000 * $sec + $msec;
587 if ( $ts > 2 ** 52 ) {
588 throw new RuntimeException( __METHOD__ .
589 ': sorry, this function doesn\'t work after the year 144680' );
590 }
591
592 return substr( \Wikimedia\base_convert( $ts, 10, 2, 46 ), -46 );
593 }
594
601 protected function intervalsSinceGregorianBinary( array $time, $delta = 0 ) {
602 list( $sec, $msec ) = $time;
603 $offset = '122192928000000000';
604 if ( PHP_INT_SIZE >= 8 ) { // 64 bit integers
605 $ts = ( 1000 * $sec + $msec ) * 10000 + (int)$offset + $delta;
606 $id_bin = str_pad( decbin( $ts % ( 2 ** 60 ) ), 60, '0', STR_PAD_LEFT );
607 } elseif ( extension_loaded( 'gmp' ) ) {
608 $ts = gmp_add( gmp_mul( (string)$sec, '1000' ), (string)$msec ); // ms
609 $ts = gmp_add( gmp_mul( $ts, '10000' ), $offset ); // 100ns intervals
610 $ts = gmp_add( $ts, (string)$delta );
611 $ts = gmp_mod( $ts, gmp_pow( '2', '60' ) ); // wrap around
612 $id_bin = str_pad( gmp_strval( $ts, 2 ), 60, '0', STR_PAD_LEFT );
613 } elseif ( extension_loaded( 'bcmath' ) ) {
614 $ts = bcadd( bcmul( $sec, 1000 ), $msec ); // ms
615 $ts = bcadd( bcmul( $ts, 10000 ), $offset ); // 100ns intervals
616 $ts = bcadd( $ts, $delta );
617 $ts = bcmod( $ts, bcpow( 2, 60 ) ); // wrap around
618 $id_bin = \Wikimedia\base_convert( $ts, 10, 2, 60 );
619 } else {
620 throw new RuntimeException( 'bcmath or gmp extension required for 32 bit machines.' );
621 }
622 return $id_bin;
623 }
624
628 private function load() {
629 if ( $this->loaded ) {
630 return; // already called
631 }
632
633 $this->loaded = true;
634
635 $nodeId = '';
636 if ( is_file( $this->nodeIdFile ) ) {
637 $nodeId = file_get_contents( $this->nodeIdFile );
638 }
639 // Try to get some ID that uniquely identifies this machine (RFC 4122)...
640 if ( !preg_match( '/^[0-9a-f]{12}$/i', $nodeId ) ) {
641 AtEase::suppressWarnings();
642 if ( PHP_OS_FAMILY === 'Windows' ) {
643 // https://technet.microsoft.com/en-us/library/bb490913.aspx
644 $csv = trim( ( $this->shellCallback )( 'getmac /NH /FO CSV' ) );
645 $line = substr( $csv, 0, strcspn( $csv, "\n" ) );
646 $info = str_getcsv( $line );
647 $nodeId = isset( $info[0] ) ? str_replace( '-', '', $info[0] ) : '';
648 } elseif ( is_executable( '/sbin/ifconfig' ) ) { // Linux/BSD/Solaris/OS X
649 // See https://linux.die.net/man/8/ifconfig
650 $m = [];
651 preg_match( '/\s([0-9a-f]{2}(?::[0-9a-f]{2}){5})\s/',
652 ( $this->shellCallback )( '/sbin/ifconfig -a' ), $m );
653 $nodeId = isset( $m[1] ) ? str_replace( ':', '', $m[1] ) : '';
654 }
655 AtEase::restoreWarnings();
656 if ( !preg_match( '/^[0-9a-f]{12}$/i', $nodeId ) ) {
657 $nodeId = bin2hex( random_bytes( 12 / 2 ) );
658 $nodeId[1] = dechex( hexdec( $nodeId[1] ) | 0x1 ); // set multicast bit
659 }
660 file_put_contents( $this->nodeIdFile, $nodeId ); // cache
661 }
662 $this->nodeId32 = \Wikimedia\base_convert( substr( sha1( $nodeId ), 0, 8 ), 16, 2, 32 );
663 $this->nodeId48 = \Wikimedia\base_convert( $nodeId, 16, 2, 48 );
664 }
665
669 private function getNodeId32() {
670 $this->load();
671
672 return $this->nodeId32;
673 }
674
678 private function getNodeId48() {
679 $this->load();
680
681 return $this->nodeId48;
682 }
683
695 private function deleteCacheFiles() {
696 foreach ( $this->fileHandles as $path => $handle ) {
697 if ( $handle !== null ) {
698 fclose( $handle );
699 }
700 if ( is_file( $path ) ) {
701 unlink( $path );
702 }
703 unset( $this->fileHandles[$path] );
704 }
705 if ( is_file( $this->nodeIdFile ) ) {
706 unlink( $this->nodeIdFile );
707 }
708 }
709
722 public function unitTestTearDown() {
723 $this->deleteCacheFiles();
724 }
725
726 public function __destruct() {
727 // @phan-suppress-next-line PhanPluginUseReturnValueInternalKnown
728 array_map( 'fclose', array_filter( $this->fileHandles ) );
729 }
730}
Class for getting statistically unique IDs without a central coordinator.
newRawUUIDv1()
Return an RFC4122 compliant v1 UUID.
const CLOCK_OFFSET
Key used in the serialized clock state map that is stored on disk.
newTimestampedUID88(int $base=10)
Get a statistically unique 88-bit unsigned integer ID string.
newSequentialPerNodeID( $bucket, $bits=48, $flags=0)
Return an ID that is sequential only for this node and bucket.
newTimestampedUID128(int $base=10)
Get a statistically unique 128-bit unsigned integer ID string.
newUUIDv4()
Return an RFC4122 compliant v4 UUID.
getSequentialPerNodeIDs( $bucket, $bits, $count, $flags)
Return IDs that are sequential only for this node and bucket.
newRawUUIDv4()
Return an RFC4122 compliant v4 UUID.
const FILE_PREFIX
Avoid using CLASS so namespace separators aren't interpreted as path components on Windows (T259693)
const CLOCK_OFFSET_COUNTER
Key used in the serialized clock state map that is stored on disk.
unitTestTearDown()
Cleanup resources when tearing down after a unit test (T46850)
string $tmpDir
Temporary directory.
string $nodeId32
Node ID in binary (32 bits)
string $nodeId48
Node ID in binary (48 bits)
const CLOCK_COUNTER
Key used in the serialized clock state map that is stored on disk.
__construct( $tempDirectory, $shellCallback)
timeWaitUntil( $time)
Wait till the current timestamp reaches $time and return the current timestamp.
bool $loaded
Whether initialization completed.
newUUIDv1()
Return an RFC4122 compliant v1 UUID.
string $lockFile128
Local file path.
array $fileHandles
Cached file handles.
getTimestampFromUUIDv1(string $uuid, int $format=TS_MW)
Get timestamp in a specified format from UUIDv1.
callable $shellCallback
Callback for running shell commands.
getTimeAndDelay( $lockFile, $clockSeqSize, $counterSize, $offsetSize)
Get a (time,counter,clock sequence) where (time,counter) is higher than any previous (time,...
string $lockFileUUID
Local file path.
load()
Load the node ID information.
newSequentialPerNodeIDs( $bucket, $bits, $count, $flags=0)
Return IDs that are sequential only for this node and bucket.
const CLOCK_TIME
Key used in the serialized clock state map that is stored on disk.
const CLOCK_SEQUENCE
Key used in the serialized clock state map that is stored on disk.
intervalsSinceGregorianBinary(array $time, $delta=0)
deleteCacheFiles()
Delete all cache files that have been created (T46850)
$line
Definition mcc.php:119
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...