Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion system/Debug/Toolbar/Collectors/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Routes extends BaseCollector
* Returns the data of this collector to be formatted in the toolbar
*
* @return array{
* matchedRoute: array<array{
* matchedRoute: list<array{
* directory: string,
* controller: string,
* method: string,
Expand Down
20 changes: 16 additions & 4 deletions system/Email/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class Email
/**
* SMTP Connection socket placeholder
*
* @var resource|null
* @var false|resource|null
*/
protected $SMTPConnect;

Expand Down Expand Up @@ -1886,7 +1886,7 @@ protected function SMTPEnd()
*/
protected function SMTPConnect()
{
if (is_resource($this->SMTPConnect)) {
if ($this->isSMTPConnected()) {
return true;
}

Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)';
}
}
2 changes: 1 addition & 1 deletion system/Router/RouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1724,7 +1724,7 @@ public function resetRoutes()
* @return array<
* string,
* array{
* filter?: string|list<string>, namespace?: string, hostname?: string,
* filter?: list<string>|string, namespace?: string, hostname?: string,
* subdomain?: string, offset?: int, priority?: int, as?: string,
* redirect?: int
* }
Expand Down
4 changes: 2 additions & 2 deletions system/Test/Mock/MockConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class MockConnection extends BaseConnection
{
/**
* @var array{
* connect?: object|resource|false|list<object|resource|false>,
* execute?: object|resource|false,
* connect?: false|list<false|object|resource>|object|resource,
* execute?: false|object|resource,
* }
*/
protected $returnValues = [];
Expand Down
1 change: 1 addition & 0 deletions user_guide_src/source/changelogs/v4.6.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_
Expand Down
Loading