[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Remove wf* function dependencies from FSLockManager

2016-09-18 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Remove wf* function dependencies from FSLockManager
..


Remove wf* function dependencies from FSLockManager

Change-Id: I52f08c6e7372ddbbcc1b5f82d505e435b01ff138
---
M includes/db/DatabaseSqlite.php
M includes/filebackend/lockmanager/FSLockManager.php
M includes/filebackend/lockmanager/LockManager.php
3 files changed, 16 insertions(+), 6 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/db/DatabaseSqlite.php b/includes/db/DatabaseSqlite.php
index 28fb5b5..a52c2ed 100644
--- a/includes/db/DatabaseSqlite.php
+++ b/includes/db/DatabaseSqlite.php
@@ -69,8 +69,10 @@
// Super doesn't open when $user is false, but we can 
work with $dbName,
// which is derived from the file path in this case.
$this->openFile( $p['dbFilePath'] );
+   $lockDomain = md5( $p['dbFilePath'] );
} else {
$this->mDBname = $p['dbname'];
+   $lockDomain = $this->mDBname;
// Stock wiki mode using standard file names per DB.
parent::__construct( $p );
// Super doesn't open when $user is false, but we can 
work with $dbName
@@ -96,7 +98,10 @@
wfWarn( "Invalid SQLite transaction mode provided." );
}
 
-   $this->lockMgr = new FSLockManager( [ 'lockDirectory' => 
"{$this->dbDir}/locks" ] );
+   $this->lockMgr = new FSLockManager( [
+   'domain' => $lockDomain,
+   'lockDirectory' => "{$this->dbDir}/locks"
+   ] );
}
 
/**
diff --git a/includes/filebackend/lockmanager/FSLockManager.php 
b/includes/filebackend/lockmanager/FSLockManager.php
index 8e149d6..b6629aa 100644
--- a/includes/filebackend/lockmanager/FSLockManager.php
+++ b/includes/filebackend/lockmanager/FSLockManager.php
@@ -41,10 +41,14 @@
self::LOCK_EX => self::LOCK_EX
];
 
-   protected $lockDir; // global dir for all servers
+   /** @var string Global dir for all servers */
+   protected $lockDir;
 
/** @var array Map of (locked key => lock file handle) */
protected $handles = [];
+
+   /** @var bool */
+   protected $isWindows;
 
/**
 * Construct a new instance from configuration.
@@ -56,6 +60,7 @@
parent::__construct( $config );
 
$this->lockDir = $config['lockDirectory'];
+   $this->isWindows = ( strtoupper( substr( PHP_OS, 0, 3 ) ) === 
'WIN' );
}
 
/**
@@ -119,11 +124,11 @@
} else {
MediaWiki\suppressWarnings();
$handle = fopen( $this->getLockPath( $path ), 
'a+' );
-   MediaWiki\restoreWarnings();
if ( !$handle ) { // lock dir missing?
-   wfMkdirParents( $this->lockDir );
+   mkdir( $this->lockDir, 0777, true );
$handle = fopen( $this->getLockPath( 
$path ), 'a+' ); // try again
}
+   MediaWiki\restoreWarnings();
}
if ( $handle ) {
// Either a shared or exclusive lock
@@ -173,7 +178,7 @@
}
// Unlock handles to release locks and delete
// any lock files that end up with no locks on them...
-   if ( wfIsWindows() ) {
+   if ( $this->isWindows ) {
// Windows: for any process, including this one,
// calling unlink() on a locked file will fail
$status->merge( $this->closeLockHandles( $path, 
$handlesToClose ) );
diff --git a/includes/filebackend/lockmanager/LockManager.php 
b/includes/filebackend/lockmanager/LockManager.php
index eff031b..e7f37ed 100644
--- a/includes/filebackend/lockmanager/LockManager.php
+++ b/includes/filebackend/lockmanager/LockManager.php
@@ -70,7 +70,7 @@
 *   This only applies if locks are not tied to a 
connection/process.
 */
public function __construct( array $config ) {
-   $this->domain = isset( $config['domain'] ) ? $config['domain'] 
: wfWikiID();
+   $this->domain = isset( $config['domain'] ) ? $config['domain'] 
: 'global';
if ( isset( $config['lockTTL'] ) ) {
$this->lockTTL = max( 5, $config['lockTTL'] );
} elseif ( PHP_SAPI === 'cli' ) {

-- 
To view, 

[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Remove wf* function dependencies from FSLockManager

2016-09-17 Thread Aaron Schulz (Code Review)
Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/311313

Change subject: Remove wf* function dependencies from FSLockManager
..

Remove wf* function dependencies from FSLockManager

Change-Id: I52f08c6e7372ddbbcc1b5f82d505e435b01ff138
---
M includes/filebackend/lockmanager/FSLockManager.php
M includes/filebackend/lockmanager/LockManager.php
2 files changed, 10 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/13/311313/1

diff --git a/includes/filebackend/lockmanager/FSLockManager.php 
b/includes/filebackend/lockmanager/FSLockManager.php
index 8e149d6..b6629aa 100644
--- a/includes/filebackend/lockmanager/FSLockManager.php
+++ b/includes/filebackend/lockmanager/FSLockManager.php
@@ -41,10 +41,14 @@
self::LOCK_EX => self::LOCK_EX
];
 
-   protected $lockDir; // global dir for all servers
+   /** @var string Global dir for all servers */
+   protected $lockDir;
 
/** @var array Map of (locked key => lock file handle) */
protected $handles = [];
+
+   /** @var bool */
+   protected $isWindows;
 
/**
 * Construct a new instance from configuration.
@@ -56,6 +60,7 @@
parent::__construct( $config );
 
$this->lockDir = $config['lockDirectory'];
+   $this->isWindows = ( strtoupper( substr( PHP_OS, 0, 3 ) ) === 
'WIN' );
}
 
/**
@@ -119,11 +124,11 @@
} else {
MediaWiki\suppressWarnings();
$handle = fopen( $this->getLockPath( $path ), 
'a+' );
-   MediaWiki\restoreWarnings();
if ( !$handle ) { // lock dir missing?
-   wfMkdirParents( $this->lockDir );
+   mkdir( $this->lockDir, 0777, true );
$handle = fopen( $this->getLockPath( 
$path ), 'a+' ); // try again
}
+   MediaWiki\restoreWarnings();
}
if ( $handle ) {
// Either a shared or exclusive lock
@@ -173,7 +178,7 @@
}
// Unlock handles to release locks and delete
// any lock files that end up with no locks on them...
-   if ( wfIsWindows() ) {
+   if ( $this->isWindows ) {
// Windows: for any process, including this one,
// calling unlink() on a locked file will fail
$status->merge( $this->closeLockHandles( $path, 
$handlesToClose ) );
diff --git a/includes/filebackend/lockmanager/LockManager.php 
b/includes/filebackend/lockmanager/LockManager.php
index eff031b..e7f37ed 100644
--- a/includes/filebackend/lockmanager/LockManager.php
+++ b/includes/filebackend/lockmanager/LockManager.php
@@ -70,7 +70,7 @@
 *   This only applies if locks are not tied to a 
connection/process.
 */
public function __construct( array $config ) {
-   $this->domain = isset( $config['domain'] ) ? $config['domain'] 
: wfWikiID();
+   $this->domain = isset( $config['domain'] ) ? $config['domain'] 
: 'global';
if ( isset( $config['lockTTL'] ) ) {
$this->lockTTL = max( 5, $config['lockTTL'] );
} elseif ( PHP_SAPI === 'cli' ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/311313
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I52f08c6e7372ddbbcc1b5f82d505e435b01ff138
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits