user_guide_src/source/changelogs/v4.2.0.rst
Version 4.2.0 #############
Release Date: June 3, 2022
4.2.0 release of CodeIgniter4
.. contents:: :local: :depth: 2
Highlights
ytetsuro <https://github.com/ytetsuro>). See Database.kenjis <https://github.com/kenjis>). See New Improved Auto Routing.Andrey Pyzhikov <https://github.com/iRedds>). See Database.@fdomgjoni99 <https://github.com/fdomgjoni99>_ made their first contribution in #5608 <https://github.com/codeigniter4/CodeIgniter4/pull/5608>_@Nudasoft <https://github.com/Nudasoft>_ made their first contribution in #5715 <https://github.com/codeigniter4/CodeIgniter4/pull/5715>_@beganovich <https://github.com/beganovich>_ made their first contribution in #5823 <https://github.com/codeigniter4/CodeIgniter4/pull/5823>_@tcgumus <https://github.com/tcgumus>_ made their first contribution in #5851 <https://github.com/codeigniter4/CodeIgniter4/pull/5851>_@michaelrk02 <https://github.com/michaelrk02>_ made their first contribution in #5878 <https://github.com/codeigniter4/CodeIgniter4/pull/5878>_@datamweb <https://github.com/datamweb>_ made their first contribution in #5894 <https://github.com/codeigniter4/CodeIgniter4/pull/5894>_@xlii-chl <https://github.com/xlii-chl>_ made their first contribution in #5884 <https://github.com/codeigniter4/CodeIgniter4/pull/5884>_@valmorflores <https://github.com/valmorflores>_ made their first contribution in #6051 <https://github.com/codeigniter4/CodeIgniter4/pull/6051>_@tearoom6 <https://github.com/tearoom6>_ made their first contribution in #6012 <https://github.com/codeigniter4/CodeIgniter4/pull/6012>_@lonnie-vault <https://github.com/lonnie-vault>_ made their first contribution in #6060 <https://github.com/codeigniter4/CodeIgniter4/pull/6060>_BREAKING
CodeIgniter\Database\BaseBuilder::join() and CodeIgniter\Database\*\Builder::join() have been changed.Validation::setRule() has been changed. The string typehint on the $rules parameter was removed. Extending classes should likewise remove the parameter so as not to break LSP.CodeIgniter\CLI\CommandRunner::_remap() has been changed to fix a bug.Service::reset() and CIUnitTestCase::resetServices() have been changed from false to true. This is to eliminate unexpected problems during testing, such as lang() not getting translated messages.CodeIgniter\CodeIgniter class has a new property $context and it must have the correct context at runtime. So the following files have been changed:
public/index.phpsparksystem/bootstrap.php file has been modified to easily implement Preloading <https://www.php.net/manual/en/opcache.preloading.php>_. Returning a CodeIgniter instance and loading .env file have been moved to index.php and spark.CodeIgniter\Autoloader\Autoloader::initialize() has changed the behavior to fix a bug. It used to use Composer classmap only when $modules->discoverInComposer is true. Now it always uses the Composer classmap if Composer is available.CLI::color() <cli-library-color> has been changed to fix a bug.$routes->cli()), all methods of that controller are no longer accessible via auto-routing.History::setFiles() method.dot_array_search()'s unexpected behavior has been fixed. Now dot_array_search('foo.bar.baz', ['foo' => ['bar' => 23]]) returns null. The previous versions returned 23.CodeIgniter::storePreviousURL() has been changed to store only the URLs whose Content-Type was text/html. It also affects the behavior of :php:func:previous_url() and :php:func:redirect()->back() <redirect>.Enhancements
.. _v420-new-improved-auto-routing:
Added an optional new more secure auto router. These are the changes from the legacy auto-routing:
getIndex(), postCreate().
Home by default) and the Default Method (index by default) must be omitted in the URI.
/, but /home and /home/index will be 404._remap() method.
See :ref:auto-routing-improved for the details.
query-builder-from-subquery.query-builder-select.BaseBuilder::buildSubquery() method can take an optional third argument string $alias.query-builder-union.CodeIgniter\Database\RawSql which expresses raw SQL strings.select() <query-builder-select-rawsql>, :ref:where() <query-builder-where-rawsql>, :ref:like() <query-builder-like-rawsql>, :ref:join() <query-builder-join-rawsql> accept the CodeIgniter\Database\RawSql instance.DBForge::addField() default value raw SQL string support. See :ref:forge-addfield-default-value-rawsql.foreignKeys that enables foreign key constraints.script_tag() now uses null values to write boolean attributes in minimized form: <script src="..." defer />. See the sample code for :php:func:script_tag().$includeDir to get_filenames(). See :php:func:get_filenames().log_message() has now improved. It now includes the file and line where the exception originated. It also does not truncate the message anymore.
spark db:table command. See :doc:../dbmgmt/db_commands for the details.
spark db:table --showspark db:table my_tablespark db:table my_table --limit-rows 50 --limit-field-value 20 --descspark db:table my_table --metadataspark routes command now shows closure routes, auto routes, and filters. See :ref:URI Routing <routing-spark-routes>.$this->validateData() in Controller. See :ref:controller-validatedata.$scriptNonceTag and $styleNonceTag in Config\ContentSecurityPolicy to customize the CSP placeholders ({csp-script-nonce} and {csp-style-nonce})$autoNonce in Config\ContentSecurityPolicy to disable the CSP placeholder replacementcsp_script_nonce() and csp_style_nonce() to get nonce attributescontent-security-policy for details.../outgoing/view_decorators allow modifying the generated HTML prior to caching.validation-traditional-and-strict-rules.RouteCollection::addRedirect() can now use placeholders. See :ref:redirecting-routes for details.microtime() instead of time().Preloading <https://www.php.net/manual/en/opcache.preloading.php>_. See preload.php.Changes
validation-getting-all-errors.Validation::getError() when using a wildcard will return all found errors matching the mask as a string.Response class. Now the Session class doesn't send cookies, set them to the Response.Deprecations
CodeIgniter\Database\SQLSRV\Connection::getError() is deprecated. Use CodeIgniter\Database\SQLSRV\Connection::error() instead.CodeIgniter\Debug\Exceptions::cleanPath() and CodeIgniter\Debug\Toolbar\Collectors\BaseCollector::cleanPath() are deprecated. Use the clean_path() function instead.CodeIgniter\Log\Logger::cleanFilenames() and CodeIgniter\Test\TestLogger::cleanup() are both deprecated. Use the clean_path() function instead.CodeIgniter\Router\Router::setDefaultController() is deprecated.SPARKED in spark is deprecated. Use the $context property in CodeIgniter\CodeIgniter instead.CodeIgniter\Autoloader\Autoloader::discoverComposerNamespaces() is deprecated, and no longer used.EVENT_PRIORITY_LOW, EVENT_PRIORITY_NORMAL and EVENT_PRIORITY_HIGH are deprecated. Use the class constants CodeIgniter\Events\Events::PRIORITY_LOW, CodeIgniter\Events\Events::PRIORITY_NORMAL and CodeIgniter\Events\Events::PRIORITY_HIGH instead.Bugs Fixed
See the repo's
CHANGELOG_4.2.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/changelogs/CHANGELOG_4.2.md>_
for a complete list of bugs fixed.