Version 4.0.5
Release Date: January 31, 2021
4.0.5 release of CodeIgniter4
Enhancements
New URL helper function
url_to()which creates absolute URLs based on controllers.New Model option:
$useAutoIncrementwhich when set tofalseallows you to provide your own primary key for each record in the table. Handy when we want to implement 1:1 relation or use UUIDs for our model.New URL helper function
url_is()which allows you to check the current URL to see if matches the given string.Services now have their config parameters strictly typehinted. This will ensure no one will pass a different config instance. If you need to pass a new config with additional properties, you need to extend that particular config.
Support for setting SameSite attribute on Session and CSRF cookies has been added. For security and compatibility with latest browser versions, the default setting is
Lax.Guessing file extensions from mime type in
Config\Mimes::guessExtensionFromType()now only reverse searches the$mimesarray if no extension is proposed (i.e., usually not for uploaded files).The getter functions for file extensions of uploaded files now have different fallback values (
UploadedFile::getClientExtension()forUploadedFile::getExtension()and''forUploadedFile::guessExtension()). This is a security fix and makes the process less dependent on the client.The Cache
FileHandlernow allows setting the file permissions mode viaConfig\Cache.
Changes
System messages defined in system/Language/en/ are now strictly for internal framework use and are not covered by backwards compatibility (BC) promise. Users may use these messages in their applications but at their own risks.
Deprecations
Deprecated
BaseCommand::getPad()in favor ofBaseCommand::setPad().Deprecated
CodeIgniter\Controller::loadHelpers()in favor ofhelper()function.Deprecated
Config\Format::getFormatter()in favor ofCodeIgniter\Format\Format::getFormatter()Deprecated
CodeIgniter\Security\Security::CSRFVerify()in favor ofCodeIgniter\Security\Security::verify()Deprecated
CodeIgniter\Security\Security::getCSRFHash()in favor ofCodeIgniter\Security\Security::getHash()Deprecated
CodeIgniter\Security\Security::getCSRTokenName()in favor ofCodeIgniter\Security\Security::getTokenName()Deprecated
Config\App::$CSRFTokenNamein favor ofConfig\Security::$tokenNameDeprecated
Config\App::$CSRFHeaderNamein favor ofConfig\Security::$headerNameDeprecated
Config\App::$CSRFCookieNamein favor ofConfig\Security::$cookieNameDeprecated
Config\App::$CSRFExpirein favor ofConfig\Security::$expireDeprecated
Config\App::$CSRFRegeneratein favor ofConfig\Security::$regenerateDeprecated
Config\App::$CSRFRedirectin favor ofConfig\Security::$redirectDeprecated
Config\App::$CSRFSameSitein favor ofConfig\Security::$samesiteDeprecated
migrate:createcommand in favor ofmake:migrationcommand.Deprecated
CodeIgniter\Database\ModelFactoryin favor ofCodeIgniter\Config\Factories::models()Deprecated
CodeIgniter\Config\Configin favor ofCodeIgniter\Config\Factories::config()Deprecated
CodeIgniter\HTTP\Message::getHeader()in favor ofheader()to prepare for PSR-7Deprecated
CodeIgniter\HTTP\Message::getHeaders()in favor ofheaders()to prepare for PSR-7Deprecated
Config\Cache::$storePathin favor ofConfig\Cache::$file['storePath']
Bugs Fixed
Fixed a bug in
Entityclass where declaring class parameters was preventing data propagation to theattributesarray.Handling for the environment variable
encryption.keyhas changed. Previously, explicit function calls, likegetenv('encryption.key')orenv('encryption.key')where the value has the special prefixhex2bin:returns an automatically converted binary string. This is now changed to just return the character string with the prefix. This change was due to incompatibility with handling binary strings in environment variables on Windows platforms. However, accessing$keyusingEncryptionclass config remains unchanged and still returns a binary string.Config\Services(in app/Config/Services.php) now extendsCodeIgniter\Config\BaseServiceto allow proper discovery of third-party services.
See the repo’s CHANGELOG_4.0.md for a complete list of bugs fixed.