Skip to content

Commit

Permalink
Merge pull request #2 from dealnews/next
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
brianlmoon authored May 16, 2024
2 parents e549043 + b45ac73 commit c45ee2e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/AbstractMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ protected function saveRelationalObjects(object $object, string $property, array

foreach ($objects as $key => $obj) {
$prop = $mapping['foreign_property'] ?? $mapping['foreign_column'] ?? null;
if (property_exists($object, $prop)) {
if (property_exists($obj, $prop)) {
// @phan-suppress-next-line PhanTypeArraySuspicious, PhanTypeInvalidDimOffset
$obj->{$prop} = $this->getValue($object, $this::PRIMARY_KEY, $this::MAPPING[$this::PRIMARY_KEY]);
}
Expand Down
18 changes: 3 additions & 15 deletions src/PDO.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,7 @@ public function connect($reconnect = false, ?string $pdo_class = \PDO::class) {
} catch (\PDOException $e) {
// add logging for failures
if ($x >= $this::RETRY_LIMIT) {
throw new \PDOException(
"Attempted to connect $x times and failed: " . $e->getMessage(),
$e->getCode(),
$e
);
throw $e;
}
}
}
Expand Down Expand Up @@ -239,11 +235,7 @@ public function __call($method, $args = []) {
);
} catch (\PDOException $e) {
if ($x >= $this::RETRY_LIMIT || !$this->checkErrorCode($e->getCode())) {
throw new \PDOException(
"Attempted to connect $x times and failed: " . $e->getMessage(),
(int)$e->getCode(),
$e
);
throw $e;
}
}
}
Expand Down Expand Up @@ -285,11 +277,7 @@ public function query(string $statement) {
}
} catch (\PDOException $e) {
if ($x >= $this::RETRY_LIMIT || !$this->checkErrorCode($e->getCode())) {
throw new \PDOException(
"Attempted to connect $x times and failed: " . $e->getMessage(),
$e->getCode(),
$e
);
throw $e;
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/PDOStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ public function execute(?array $input_parameters = []) {
// if we get here, we didn't get true in $result
if ($x >= PDO::RETRY_LIMIT || !$this->pdo->checkErrorCode($this->stmt->errorCode())) {
if (isset($result) && is_object($result)) {
throw $result;
} else {
throw new \PDOException(
"Attempted run query $x times and failed: " . $result->getMessage(),
$result->getCode(),
"Attempted run query $x times and failed",
999,
$result
);
}
Expand Down

0 comments on commit c45ee2e

Please sign in to comment.