Skip to content

Commit 0d24301

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 9a710ba + 27c4142 commit 0d24301

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

src/Bean.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function offsetUnset($offset) : void
108108
*/
109109
public function refresh() : void
110110
{
111-
$this->row = $this->row->getTable()->get($this->primaryKey->getValue());
111+
$this->row = $this->row->getTable()->createSelectionInstance($this->getTableName())->get($this->primaryKey->getValue());
112112
$this->initiateProperties();
113113
}
114114

src/Bridge/Nette/Connection.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,30 @@
66

77
final class Connection extends \Nette\Database\Connection
88
{
9-
public function query(string $sql, ...$params): \Nette\Database\ResultSet
9+
public function connect() : void
1010
{
1111
try {
12-
return parent::query($sql, $params);
12+
parent::connect();
13+
} catch (\PDOException $e) {
14+
if (\str_contains($e->getMessage(), 'reset by peer')) {
15+
parent::connect(); // retry
16+
17+
return;
18+
}
19+
20+
throw $e;
21+
}
22+
}
23+
24+
public function query(string $sql, ...$params) : \Nette\Database\ResultSet
25+
{
26+
try {
27+
return parent::query($sql, ...$params);
1328
} catch (\PDOException $e) {
1429
if ($e->getCode() === 'HY000' && \str_contains($e->getMessage(), 'gone away')) {
1530
$this->reconnect();
1631

17-
return parent::query($sql, $params); // retry
32+
return parent::query($sql, ...$params); // retry
1833
}
1934

2035
throw $e;

src/Selection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function count() : int
146146
/**
147147
* Clones object - same as: $copy = clone $orig;
148148
*/
149-
public function clone() : self
149+
public function clone() : static
150150
{
151151
$newSel = clone $this->selection;
152152

0 commit comments

Comments
 (0)