Skip to content

Commit 598d058

Browse files
committed
uuid\GlobalIdGenerator: Check if getmyuid() exists
Wiki hosting services could disable this function for security reasons Bug: T324513 Change-Id: I9a296eca3f20c82258a7f5012d00d1f0fee76bcd
1 parent 5cbc8f4 commit 598d058

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

includes/libs/uuid/GlobalIdGenerator.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class GlobalIdGenerator {
3939
protected $tmpDir;
4040
/** @var string
4141
* File prefix containing user ID to prevent collisions
42-
* if multiple users run MediaWiki (T268420)
42+
* if multiple users run MediaWiki (T268420) and getmyuid() is enabled
4343
*/
4444
protected $uniqueFilePrefix;
4545
/** @var string Local file path */
@@ -97,7 +97,9 @@ public function __construct( $tempDirectory, $shellCallback ) {
9797
throw new InvalidArgumentException( "No temp directory provided" );
9898
}
9999
$this->tmpDir = $tempDirectory;
100-
$this->uniqueFilePrefix = self::FILE_PREFIX . getmyuid();
100+
// Check if getmyuid exists, it could be disabled for security reasons - T324513
101+
$fileSuffix = function_exists( 'getmyuid' ) ? getmyuid() : '';
102+
$this->uniqueFilePrefix = self::FILE_PREFIX . $fileSuffix;
101103
$this->nodeIdFile = $tempDirectory . '/' . $this->uniqueFilePrefix . '-UID-nodeid';
102104
// If different processes run as different users, they may have different temp dirs.
103105
// This is dealt with by initializing the clock sequence number and counters randomly.

0 commit comments

Comments
 (0)