Skip to content

Commit f699739

Browse files
committed
Filter non-IO methods
1 parent 7c92ed5 commit f699739

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

src/core/Database/MysqliProxy.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@ public function __construct(callable $constructor)
4949
public function __call(string $name, array $arguments)
5050
{
5151
for ($n = 3; $n--;) {
52+
$this->__object->errno = 0;
5253
$ret = @$this->__object->{$name}(...$arguments);
5354
if ($ret === false) {
55+
/* no error */
56+
if ($this->__object->errno === 0) {
57+
break;
58+
}
5459
/* no more chances or non-IO failures */
5560
if (
5661
!in_array($this->__object->errno, static::IO_ERRORS, true) ||

src/core/Database/MysqliStatementProxy.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@ public function __construct(mysqli_stmt $object, ?string $queryString, MysqliPro
4949
public function __call(string $name, array $arguments)
5050
{
5151
for ($n = 3; $n--;) {
52+
$this->__object->errno = 0;
5253
$ret = @$this->__object->{$name}(...$arguments);
5354
if ($ret === false) {
55+
/* no error */
56+
if ($this->__object->errno === 0) {
57+
break;
58+
}
5459
/* no more chances or non-IO failures or in transaction */
5560
if (
5661
!in_array($this->__object->errno, $this->parent::IO_ERRORS, true) ||

src/core/Database/PDOProxy.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
class PDOProxy extends ObjectProxy
1919
{
20+
public const IO_METHOD_REGEX = '/^query|prepare|exec|beginTransaction|commit|rollback$/i';
2021
public const IO_ERRORS = [
2122
2002, // MYSQLND_CR_CONNECTION_ERROR
2223
2006, // MYSQLND_CR_SERVER_GONE_ERROR
@@ -47,8 +48,12 @@ public function __call(string $name, array $arguments)
4748
for ($n = 3; $n--;) {
4849
$ret = @$this->__object->{$name}(...$arguments);
4950
if ($ret === false) {
50-
/* no more chances or non-IO failures */
51+
/* non-IO method */
52+
if (!preg_match(static::IO_METHOD_REGEX, $name)) {
53+
break;
54+
}
5155
$errorInfo = $this->__object->errorInfo();
56+
/* no more chances or non-IO failures */
5257
if (
5358
!in_array($errorInfo[1], static::IO_ERRORS, true) ||
5459
$n === 0 ||

src/core/Database/PDOStatementProxy.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ public function __call(string $name, array $arguments)
5454
for ($n = 3; $n--;) {
5555
$ret = @$this->__object->{$name}(...$arguments);
5656
if ($ret === false) {
57+
/* no IO */
58+
if (strtolower($name) !== 'execute') {
59+
break;
60+
}
5761
/* no more chances or non-IO failures or in transaction */
5862
if (
5963
!in_array($this->__object->errorInfo()[1], $this->parent::IO_ERRORS, true) ||

0 commit comments

Comments
 (0)