Skip to content

Commit

Permalink
Merge pull request #5536 from kenjis/fix-BaseConnection-connectDuration
Browse files Browse the repository at this point in the history
fix: BaseConnection::getConnectDuration() number_format(): Passing null to parameter
  • Loading branch information
kenjis committed Jan 8, 2022
1 parent 8034422 commit 12d998a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions system/Database/BaseConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,14 @@ abstract class BaseConnection implements ConnectionInterface
*
* @var float
*/
protected $connectTime;
protected $connectTime = 0.0;

/**
* How long it took to establish connection.
*
* @var float
*/
protected $connectDuration;
protected $connectDuration = 0.0;

/**
* If true, no queries will actually be
Expand Down
10 changes: 10 additions & 0 deletions tests/system/Database/BaseConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,16 @@ public function testStoresConnectionTimings()
$this->assertGreaterThan(0.0, $db->getConnectDuration());
}

/**
* @see https://github.com/codeigniter4/CodeIgniter4/issues/5535
*/
public function testStoresConnectionTimingsNotConnected()
{
$db = new MockConnection($this->options);

$this->assertSame('0.000000', $db->getConnectDuration());
}

public function testMagicIssetTrue()
{
$db = new MockConnection($this->options);
Expand Down

0 comments on commit 12d998a

Please sign in to comment.