Thiemo Mättig (WMDE) has uploaded a new change for review.
https://gerrit.wikimedia.org/r/207750
Change subject: More clean up in DispatchStats class
......................................................................
More clean up in DispatchStats class
As suggested in I8f27fde.
Change-Id: Id54a4fae7c1eee45b6521b899878a14488911f15
---
M repo/includes/store/sql/DispatchStats.php
1 file changed, 14 insertions(+), 13 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/50/207750/1
diff --git a/repo/includes/store/sql/DispatchStats.php
b/repo/includes/store/sql/DispatchStats.php
index ae44bcb..2046c47 100644
--- a/repo/includes/store/sql/DispatchStats.php
+++ b/repo/includes/store/sql/DispatchStats.php
@@ -10,6 +10,7 @@
*
* @licence GNU GPL v2+
* @author Daniel Kinzler
+ * @author Thiemo Mättig
*/
class DispatchStats {
@@ -138,7 +139,7 @@
* @return bool
*/
public function hasStats() {
- return is_array( $this->clientStates ) && !empty(
$this->clientStates );
+ return !empty( $this->clientStates );
}
/**
@@ -167,7 +168,7 @@
* @return int
*/
public function getClientCount() {
- return count( $this->clientStates );
+ return $this->clientStates ? count( $this->clientStates ) : 0;
}
/**
@@ -176,10 +177,10 @@
*
* See getClientStates() for the structure of the status object.
*
- * @return object
+ * @return object|null
*/
public function getFreshest() {
- return end( $this->clientStates );
+ return $this->clientStates ? end( $this->clientStates ) : null;
}
/**
@@ -188,10 +189,10 @@
*
* See getClientStates() for the structure of the status object.
*
- * @return object
+ * @return object|null
*/
public function getStalest() {
- return reset( $this->clientStates );
+ return $this->clientStates ? reset( $this->clientStates ) :
null;
}
/**
@@ -203,13 +204,11 @@
* @return object|null
*/
public function getMedian() {
- $count = $this->getClientCount();
-
- if ( $count <= 0 ) {
+ if ( empty( $this->clientStates ) ) {
return null;
}
- $i = (int)( $count / 2 );
+ $i = (int)( count( $this->clientStates ) / 2 );
return $this->clientStates[$i];
}
@@ -239,9 +238,11 @@
public function getLockedCount() {
$c = 0;
- foreach ( $this->clientStates as $row ) {
- if ( $row->chd_lock !== null ) {
- $c++;
+ if ( !empty( $this->clientStates ) ) {
+ foreach ( $this->clientStates as $row ) {
+ if ( $row->chd_lock !== null ) {
+ $c++;
+ }
}
}
--
To view, visit https://gerrit.wikimedia.org/r/207750
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id54a4fae7c1eee45b6521b899878a14488911f15
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits