diff --git a/system/Debug/Toolbar/Collectors/Routes.php b/system/Debug/Toolbar/Collectors/Routes.php index 47c808e7ac40..f8005065c57e 100644 --- a/system/Debug/Toolbar/Collectors/Routes.php +++ b/system/Debug/Toolbar/Collectors/Routes.php @@ -51,7 +51,7 @@ class Routes extends BaseCollector * Returns the data of this collector to be formatted in the toolbar * * @return array{ - * matchedRoute: arraySMTPConnect)) { + if ($this->isSMTPConnected()) { return true; } @@ -1910,7 +1910,7 @@ protected function SMTPConnect() $this->SMTPTimeout, ); - if (! is_resource($this->SMTPConnect)) { + if (! $this->isSMTPConnected()) { $this->setErrorMessage(lang('Email.SMTPError', [$errno . ' ' . $errstr])); return false; @@ -2227,7 +2227,7 @@ protected function mimeTypes($ext = '') public function __destruct() { - if ($this->SMTPConnect !== null) { + if ($this->isSMTPConnected()) { try { $this->sendCommand('quit'); } catch (ErrorException $e) { @@ -2284,4 +2284,16 @@ protected function setArchiveValues(): array return $this->archive; } + + /** + * Checks if there is an active SMTP connection. + * + * @return bool True if SMTP connection is established and open, false otherwise + */ + protected function isSMTPConnected(): bool + { + return $this->SMTPConnect !== null + && $this->SMTPConnect !== false + && get_debug_type($this->SMTPConnect) !== 'resource (closed)'; + } } diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index 66c3ace6fe1a..7379d014cc09 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -1724,7 +1724,7 @@ public function resetRoutes() * @return array< * string, * array{ - * filter?: string|list, namespace?: string, hostname?: string, + * filter?: list|string, namespace?: string, hostname?: string, * subdomain?: string, offset?: int, priority?: int, as?: string, * redirect?: int * } diff --git a/system/Test/Mock/MockConnection.php b/system/Test/Mock/MockConnection.php index 2801a0674ad5..d14160595333 100644 --- a/system/Test/Mock/MockConnection.php +++ b/system/Test/Mock/MockConnection.php @@ -27,8 +27,8 @@ class MockConnection extends BaseConnection { /** * @var array{ - * connect?: object|resource|false|list, - * execute?: object|resource|false, + * connect?: false|list|object|resource, + * execute?: false|object|resource, * } */ protected $returnValues = []; diff --git a/user_guide_src/source/changelogs/v4.6.3.rst b/user_guide_src/source/changelogs/v4.6.3.rst index fa7786891956..ae525e52c3f8 100644 --- a/user_guide_src/source/changelogs/v4.6.3.rst +++ b/user_guide_src/source/changelogs/v4.6.3.rst @@ -31,6 +31,7 @@ Bugs Fixed ********** - **Email:** Fixed a bug with CID check when building email attachments. +- **Email:** Fixed a bug with SMTP connection resource validation in the class destructor. See the repo's `CHANGELOG.md `_