From 99b10314c818a5f0cd8e9dd538256837c9371e72 Mon Sep 17 00:00:00 2001 From: ping-yee <611077101@mail.nknu.edu.tw> Date: Thu, 14 Nov 2024 23:42:09 +0800 Subject: [PATCH 1/3] fix: fix the reconnect function. --- system/Database/Postgre/Connection.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/Database/Postgre/Connection.php b/system/Database/Postgre/Connection.php index 416d6e02f86f..fe47c220a335 100644 --- a/system/Database/Postgre/Connection.php +++ b/system/Database/Postgre/Connection.php @@ -149,8 +149,8 @@ private function convertDSN() */ public function reconnect() { - if (pg_ping($this->connID) === false) { - $this->connID = false; + if ($this->connID === false || pg_ping($this->connID) === false) { + $this->connect(); } } From ace329fe5a1ad73398fc6cd4f1c6a3e2e5e5fa35 Mon Sep 17 00:00:00 2001 From: ping-yee <611077101@mail.nknu.edu.tw> Date: Mon, 18 Nov 2024 16:32:45 +0800 Subject: [PATCH 2/3] fix: rebase. --- system/Database/Postgre/Connection.php | 3 ++- user_guide_src/source/changelogs/v4.5.6.rst | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/system/Database/Postgre/Connection.php b/system/Database/Postgre/Connection.php index fe47c220a335..2826ab1bf53c 100644 --- a/system/Database/Postgre/Connection.php +++ b/system/Database/Postgre/Connection.php @@ -150,7 +150,8 @@ private function convertDSN() public function reconnect() { if ($this->connID === false || pg_ping($this->connID) === false) { - $this->connect(); + $this->close(); + $this->initialize(); } } diff --git a/user_guide_src/source/changelogs/v4.5.6.rst b/user_guide_src/source/changelogs/v4.5.6.rst index 1dbaf55f2482..eebff5632051 100644 --- a/user_guide_src/source/changelogs/v4.5.6.rst +++ b/user_guide_src/source/changelogs/v4.5.6.rst @@ -41,6 +41,7 @@ Bugs Fixed - **Validation:** Fixed a bug where complex language strings were not properly handled. - **CURLRequest:** Added support for handling proxy responses using HTTP versions other than 1.1. +- **PostgreSQL Connection:** Fixed bug that PostgreSQL cannot reconnect the database with ``reconnect()`` method. See the repo's `CHANGELOG.md `_ From 0c9799fe45f9692919bb0eed340aa4e24cee1c0e Mon Sep 17 00:00:00 2001 From: ping-yee <611077101@mail.nknu.edu.tw> Date: Thu, 28 Nov 2024 20:59:13 +0800 Subject: [PATCH 3/3] docs: change the change log. --- user_guide_src/source/changelogs/v4.5.6.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/changelogs/v4.5.6.rst b/user_guide_src/source/changelogs/v4.5.6.rst index eebff5632051..9490e62e4e80 100644 --- a/user_guide_src/source/changelogs/v4.5.6.rst +++ b/user_guide_src/source/changelogs/v4.5.6.rst @@ -41,7 +41,7 @@ Bugs Fixed - **Validation:** Fixed a bug where complex language strings were not properly handled. - **CURLRequest:** Added support for handling proxy responses using HTTP versions other than 1.1. -- **PostgreSQL Connection:** Fixed bug that PostgreSQL cannot reconnect the database with ``reconnect()`` method. +- **Database:** Fixed a bug that caused ``Postgre\Connection::reconnect()`` method to throw an error when the connection had not yet been established. See the repo's `CHANGELOG.md `_