Upgrading from 4.1.1 to 4.1.2¶
Please refer to the upgrade instructions corresponding to your installation method.
- Composer Installation App Starter Upgrading
- Composer Installation Adding CodeIgniter4 to an Existing Project Upgrading
- Manual Installation Upgrading
Breaking Changes¶
current_url() and indexPage¶
Due to a bug in current_url(), the resulting URIs could be incorrect for a project's configuration, most importantly: indexPage would not be included. Projects using App::$indexPage should expect altered values from current_url() and all its dependencies (including Response Testing, Pager, Form Helper, and View Parser). Update your projects accordingly.
Cache Keys¶
Cache handlers had wildly different compatibility for keys. The updated cache drivers now pass all keys through validation, roughly matching PSR-6's recommendations:
A string of at least one character that uniquely identifies a cached item. Implementing libraries MUST support keys consisting of the characters A-Z, a-z, 0-9, _, and . in any order in UTF-8 encoding and a length of up to 64 characters. Implementing libraries MAY support additional characters and encodings or longer lengths, but must support at least that minimum. Libraries are responsible for their own escaping of key strings as appropriate, but MUST be able to return the original unmodified key string. The following characters are reserved for future extensions and MUST NOT be supported by implementing libraries: {}()/\@:
Update your projects to remove any invalid cache keys.
BaseConnection::query() Return Values¶
The BaseConnection::query() method in prior versions was incorrectly returning BaseResult objects even if the query failed. This method will now return false for failed queries (or throw an Exception if DBDebug is true) and will return booleans for write-type queries. Review any use of the query() method and assess whether the value might be boolean instead of a Result object. For a better idea of what queries are write-type queries, check BaseConnection::isWriteType() and any DBMS-specific override isWriteType() in the relevant Connection class.
Breaking Enhancements¶
ConnectionInterface::isWriteType() Declaration Added¶
If you have written any classes that implement ConnectionInterface, these must now implement the isWriteType() method, declared as public function isWriteType($sql): bool. If your class extends BaseConnection, then that class will provide a basic isWriteType() method which you might want to override.
Test Traits¶
The CodeIgniter\Test namespace has had significant improvements to help developers with their own test cases. Most notably, test extensions have moved to Traits to make them easier to pick-and-choose across various test case needs. The CIDatabaseTestCase and FeatureTestCase classes have been deprecated and their methods moved to DatabaseTestTrait and FeatureTestTrait respectively. Update your test cases to extend the main test case and use any traits you need. For example:
<?php
use CodeIgniter\Test\DatabaseTestCase;
class MyDatabaseTest extends DatabaseTestCase
{
public function testBadRow()
{
// ...
}
}
... becomes:
<?php
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\DatabaseTestTrait;
class MyDatabaseTest extends CIUnitTestCase
{
use DatabaseTestTrait;
public function testBadRow()
{
// ...
}
}
Finally, ControllerTester has been superseded by ControllerTestTrait to standardize the approach and take advantage of the updated response testing (below).
Test Responses¶
The tools for testing responses have been consolidated and improved. A new TestResponse replaces ControllerResponse and FeatureResponse with a complete set of methods and properties expected from both those classes. In most cases, these changes will be handled "behind the scenes" by ControllerTestTrait and FeatureTestCase, but there are two changes to be aware of:
TestResponse's$requestand$responseproperties are protected and should only be accessed through their getter methods,request()andresponse()TestResponsedoes not havegetBody()andsetBody()methods, but rather uses the Response methods directly, e.g.:$body = $result->response()->getBody();
Project Files¶
Numerous 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. There are some third-party CodeIgniter modules available to assist with merging changes to the project space: Explore on Packagist.
Note
Except in very rare cases for bug fixes, no changes made to files for the project space will break your application. All changes noted here are optional until the next major version, and any mandatory changes will be covered in the sections above.
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:
app/Config/App.phpapp/Config/Autoload.phpapp/Config/Cookie.phpapp/Config/Events.phpapp/Config/Exceptions.phpapp/Config/Security.phpapp/Views/errors/html/*envspark
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/App.phpapp/Config/Autoload.phpapp/Config/ContentSecurityPolicy.phpapp/Config/Cookie.phpapp/Config/Events.phpapp/Config/Exceptions.phpapp/Config/Logger.phpapp/Config/Mimes.phpapp/Config/Modules.phpapp/Config/Security.phpapp/Controllers/BaseController.phpapp/Views/errors/html/debug.cssapp/Views/errors/html/error_404.phpapp/Views/errors/html/error_exception.phpapp/Views/welcome_message.phpcomposer.jsoncontributing/guidelines.rstenvpublic/.htaccesspublic/index.phpspark