Reedy has uploaded a new change for review.
https://gerrit.wikimedia.org/r/298379
Change subject: Update arrays, calls to deprecated functions
......................................................................
Update arrays, calls to deprecated functions
Change-Id: Iac94789f274ab2d8da179b00db288185b3150834
---
M PoolCounterClient_body.php
1 file changed, 23 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PoolCounter
refs/changes/79/298379/1
diff --git a/PoolCounterClient_body.php b/PoolCounterClient_body.php
index 8353f0c..18e080a 100644
--- a/PoolCounterClient_body.php
+++ b/PoolCounterClient_body.php
@@ -2,9 +2,13 @@
class PoolCounter_ConnectionManager {
public $hostNames;
- public $conns = array();
- public $refCounts = array();
+ public $conns = [];
+ public $refCounts = [];
+ /**
+ * @param array $conf
+ * @throws MWException
+ */
function __construct( $conf ) {
$this->hostNames = $conf['servers'];
$this->timeout = isset( $conf['timeout'] ) ? $conf['timeout'] :
0.1;
@@ -20,12 +24,13 @@
* @return Status
*/
function get( $key ) {
- $hashes = array();
+ $hashes = [];
foreach ( $this->hostNames as $hostName ) {
$hashes[$hostName] = md5( $hostName . $key );
}
asort( $hashes );
$errno = $errstr = '';
+ $conn = null;
foreach ( $hashes as $hostName => $hash ) {
if ( isset( $this->conns[$hostName] ) ) {
$this->refCounts[$hostName]++;
@@ -35,9 +40,9 @@
if ( count( $parts ) < 2 ) {
$parts[] = 7531;
}
- wfSuppressWarnings();
+ MediaWiki\suppressWarnings();
$conn = $this->open( $parts[0], $parts[1], $errno,
$errstr );
- wfRestoreWarnings();
+ MediaWiki\restoreWarnings();
if ( $conn ) {
break;
}
@@ -53,6 +58,11 @@
/**
* Open a socket. Just a wrapper for fsockopen()
+ * @param string $host
+ * @param int $port
+ * @param $errno
+ * @param $errstr
+ * @return null|resource
*/
private function open( $host, $port, &$errno, &$errstr ) {
// If connect_timeout is set, we try to open the socket twice.
@@ -67,6 +77,7 @@
$timeout = $this->timeout;
}
+ $fp = null;
while ( true ) {
$fp = fsockopen( $host, $port, $errno, $errstr,
$timeout );
if ( $fp !== false || --$tries < 1 ) {
@@ -102,11 +113,18 @@
* releases all locks acquired.
*/
private $conn;
+
/**
* @var PoolCounter_ConnectionManager
*/
static private $manager;
+ /**
+ * PoolCounter_Client constructor.
+ * @param array $conf
+ * @param string $type
+ * @param string $key
+ */
function __construct( $conf, $type, $key ) {
parent::__construct( $conf, $type, $key );
if ( !self::$manager ) {
--
To view, visit https://gerrit.wikimedia.org/r/298379
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iac94789f274ab2d8da179b00db288185b3150834
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/PoolCounter
Gerrit-Branch: master
Gerrit-Owner: Reedy <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits