Jeroen De Dauw has submitted this change and it was merged. Change subject: Fix DispatchStats::hasStats ......................................................................
Fix DispatchStats::hasStats Change-Id: Ib2204df2c0a5028588634990afe7aec65847adba --- M repo/includes/store/sql/DispatchStats.php M repo/tests/phpunit/includes/store/sql/DispatchStatsTest.php 2 files changed, 26 insertions(+), 1 deletion(-) Approvals: Jeroen De Dauw: Looks good to me, approved diff --git a/repo/includes/store/sql/DispatchStats.php b/repo/includes/store/sql/DispatchStats.php index 5f9c10f..b3db135 100644 --- a/repo/includes/store/sql/DispatchStats.php +++ b/repo/includes/store/sql/DispatchStats.php @@ -156,8 +156,11 @@ return $n; } + /** + * @return bool + */ public function hasStats() { - return is_array( $this->clientStates ); + return is_array( $this->clientStates ) && !empty( $this->clientStates ); } /** diff --git a/repo/tests/phpunit/includes/store/sql/DispatchStatsTest.php b/repo/tests/phpunit/includes/store/sql/DispatchStatsTest.php index dad4c52..dea6010 100644 --- a/repo/tests/phpunit/includes/store/sql/DispatchStatsTest.php +++ b/repo/tests/phpunit/includes/store/sql/DispatchStatsTest.php @@ -446,4 +446,26 @@ $this->assertStateEquals( $expected, $stats->getStalest()); } + + public function testHasStats() { + $stats = $this->getDispatchStats(); + + $this->assertTrue( $stats->hasStats() ); + + // No stats there before load has been called. + $unloadedStats = new DispatchStats(); + $this->assertFalse( $unloadedStats->hasStats() ); + } + + public function testHasNoStats() { + $dbw = wfGetDB( DB_MASTER ); + + $dbw->delete( 'wb_changes', '*' ); + $dbw->delete( 'wb_changes_dispatch', '*' ); + + $stats = new DispatchStats(); + $stats->load( time() ); + + $this->assertFalse( $stats->hasStats() ); // Still no stats as the table is empty + } } -- To view, visit https://gerrit.wikimedia.org/r/160376 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib2204df2c0a5028588634990afe7aec65847adba Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Hoo man <h...@online.de> Gerrit-Reviewer: Aude <aude.w...@gmail.com> Gerrit-Reviewer: Bene <benestar.wikime...@gmail.com> Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Hoo man <h...@online.de> Gerrit-Reviewer: Jeroen De Dauw <jeroended...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits