Skip to content

4.6.3 Ready code #9654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Aug 2, 2025
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
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## [v4.6.3](https://github.com/codeigniter4/CodeIgniter4/tree/v4.6.3) (2025-08-02)
[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.6.2...v4.6.3)

### Fixed Bugs

* fix: CID check in Email class by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/9645
* fix: SMTP connection resource validation in `Email` class destructor by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/9648

### Refactoring

* refactor: update preload script to exclude `util_bootstrap` by @ddevsr in https://github.com/codeigniter4/CodeIgniter4/pull/9649
* refactor: phpdoc for `Config\Filters::$globals` by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/9652

## [v4.6.2](https://github.com/codeigniter4/CodeIgniter4/tree/v4.6.2) (2025-07-26)
[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.6.1...v4.6.2)

Expand Down
5 changes: 4 additions & 1 deletion app/Config/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ class Filters extends BaseFilters
* List of filter aliases that are always
* applied before and after every request.
*
* @var array<string, array<string, array<string, string>>>|array<string, list<string>>
* @var array{
* before: array<string, array{except: list<string>|string}>|list<string>,
* after: array<string, array{except: list<string>|string}>|list<string>
* }
*/
public array $globals = [
'before' => [
Expand Down
2 changes: 1 addition & 1 deletion phpdoc.dist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<output>api/build/</output>
<cache>api/cache/</cache>
</paths>
<version number="4.6.2">
<version number="4.6.3">
<api format="php">
<source dsn=".">
<path>system</path>
Expand Down
1 change: 1 addition & 0 deletions preload.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class preload
'/system/Config/Routes.php',
'/system/Language/',
'/system/bootstrap.php',
'/system/util_bootstrap.php',
'/system/rewrite.php',
'/Views/',
// Errors occur.
Expand Down
2 changes: 1 addition & 1 deletion system/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class CodeIgniter
/**
* The current version of CodeIgniter Framework
*/
public const CI_VERSION = '4.6.2';
public const CI_VERSION = '4.6.3';

/**
* App startup time.
Expand Down
5 changes: 4 additions & 1 deletion system/Config/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ class Filters extends BaseConfig
* List of filter aliases that are always
* applied before and after every request.
*
* @var array<string, array<string, array<string, string>>>|array<string, list<string>>
* @var array{
* before: array<string, array{except: list<string>|string}>|list<string>,
* after: array<string, array{except: list<string>|string}>|list<string>
* }
*/
public array $globals = [
'before' => [
Expand Down
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
22 changes: 17 additions & 5 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 @@ -1308,7 +1308,7 @@ protected function appendAttachments(&$body, $boundary, $multipart = null)
. 'Content-Type: ' . $attachment['type'] . '; name="' . $name . '"' . $this->newline
. 'Content-Disposition: ' . $attachment['disposition'] . ';' . $this->newline
. 'Content-Transfer-Encoding: base64' . $this->newline
. ($attachment['cid'] === '' ? '' : 'Content-ID: <' . $attachment['cid'] . '>' . $this->newline)
. (isset($attachment['cid']) && $attachment['cid'] !== '' ? 'Content-ID: <' . $attachment['cid'] . '>' . $this->newline : '')
. $this->newline
. $attachment['content'] . $this->newline;
}
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
36 changes: 36 additions & 0 deletions tests/system/Email/EmailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use ReflectionException;
use ReflectionMethod;

/**
* @internal
Expand Down Expand Up @@ -220,6 +221,41 @@ public function testSetAttachmentCIDBufferString(): void
);
}

/**
* @see https://github.com/codeigniter4/CodeIgniter4/issues/9644
*
* @throws ReflectionException
*/
public function testAppendAttachmentsWithoutCID(): void
{
$email = $this->createMockEmail();

// Manually inject an attachment without 'cid'
$this->setPrivateProperty($email, 'attachments', [
[
'multipart' => 'mixed',
'content' => 'VGhpcyBpcyBhIHRlc3QgZmlsZSBjb250ZW50Lg==', // base64 for "This is a test file content."
'filename' => '',
'type' => 'application/pdf',
'name' => ['testfile.pdf'],
'disposition' => 'attachment',
],
]);

$body = '';
$boundary = 'test-boundary';

// Use ReflectionMethod to call protected method with pass-by-reference
$refMethod = new ReflectionMethod($email, 'appendAttachments');
$refMethod->invokeArgs($email, [&$body, $boundary, 'mixed']);

// Assertion: Should not include a Content-ID header
$this->assertStringContainsString('Content-Type: application/pdf; name="testfile.pdf"', $body);
$this->assertStringContainsString('Content-Disposition: attachment;', $body);
$this->assertStringNotContainsString('Content-ID:', $body);
$this->assertStringContainsString('--' . $boundary . '--', $body);
}

/**
* @throws ReflectionException
*/
Expand Down
1 change: 1 addition & 0 deletions user_guide_src/source/changelogs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ See all the changes.
.. toctree::
:titlesonly:

v4.6.3
v4.6.2
v4.6.1
v4.6.0
Expand Down
22 changes: 22 additions & 0 deletions user_guide_src/source/changelogs/v4.6.3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#############
Version 4.6.3
#############

Release Date: August 2, 2025

**4.6.3 release of CodeIgniter4**

.. contents::
:local:
:depth: 3

**********
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>`_
for a complete list of bugs fixed.
2 changes: 1 addition & 1 deletion user_guide_src/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
version = '4.6'

# The full version, including alpha/beta/rc tags.
release = '4.6.2'
release = '4.6.3'

# -- General configuration ---------------------------------------------------

Expand Down
44 changes: 44 additions & 0 deletions user_guide_src/source/installation/upgrade_463.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#############################
Upgrading from 4.6.2 to 4.6.3
#############################

Please refer to the upgrade instructions corresponding to your installation method.

- :ref:`Composer Installation App Starter Upgrading <app-starter-upgrading>`
- :ref:`Composer Installation Adding CodeIgniter4 to an Existing Project Upgrading <adding-codeigniter4-upgrading>`
- :ref:`Manual Installation Upgrading <installing-manual-upgrading>`

.. contents::
:local:
:depth: 2

*************
Project Files
*************

Some files in the **project space** (root, app, public, writable) received updates. Due to
these files being outside of the **system** scope they will not be changed without your intervention.

.. note:: There are some third-party CodeIgniter modules available to assist
with merging changes to the project space:
`Explore on Packagist <https://packagist.org/explore/?query=codeigniter4%20updates>`_.

Content Changes
===============

The following files received significant changes (including deprecations or visual adjustments)
and it is recommended that you merge the updated versions with your application:

Config
------

- app/Config/Filters.php

All Changes
===========

This is a list of all files in the **project space** that received changes;
many will be simple comments or formatting that have no effect on the runtime:

- app/Config/Filters.php
- preload.php
1 change: 1 addition & 0 deletions user_guide_src/source/installation/upgrading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ See also :doc:`./backward_compatibility_notes`.

backward_compatibility_notes

upgrade_463
upgrade_462
upgrade_461
upgrade_460
Expand Down
Loading