Skip to content

Commit d20664c

Browse files
committed
Merge branch '5.x' into 5.next
2 parents 45cb9ca + fd7f467 commit d20664c

19 files changed

+104
-105
lines changed

config/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,7 @@
117117
"""
118118

119119
# todo_include_todos = True
120+
121+
# turn off contents entries for classes/functions
122+
# generally we add titles for methods and classes instead.
123+
toc_object_entries = False

en/appendices/5-0-migration-guide.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Global
4242
- MariaDB (10.1 or higher)
4343
- PostgreSQL (9.6 or higher)
4444
- Microsoft SQL Server (2012 or higher)
45-
- SQLite 3
45+
- SQLite 3 (3.16 or higher)
4646

4747
Auth
4848
----
@@ -56,6 +56,12 @@ Cache
5656
- The ``Wincache`` engine was removed. The wincache extension is not supported
5757
on PHP 8.
5858

59+
Collection
60+
----------
61+
62+
- ``combine()`` now throws an exception if the key path or group path doesn't exist or contains a null value.
63+
This matches the behavior of ``indexBy()`` and ``groupBy()``.
64+
5965
Console
6066
-------
6167

en/appendices/phpunit10.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ New event system
2121
----------------
2222

2323
PHPUnit 10 removed the old hook system and introduced a new `Event system
24-
<https://docs.phpunit.de/en/10.0/extending-phpunit.html#extending-the-test-runner>`_
24+
<https://docs.phpunit.de/en/10.5/extending-phpunit.html#extending-the-test-runner>`_
2525
which requires the following code in your ``phpunit.xml`` to be adjusted from::
2626

2727
<extensions>

en/contributing/cakephp-coding-conventions.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,17 @@ underscore character, for example::
569569

570570
define('LONG_NAMED_CONSTANT', 2);
571571

572+
Enums
573+
-----
574+
575+
Enum cases are defined in ``CamelCase`` style::
576+
577+
enum ArticleStatus: string
578+
{
579+
case Published = 'Y';
580+
case NotPublishedYet = 'N';
581+
}
582+
572583
Careful when using empty()/isset()
573584
==================================
574585

en/controllers.rst

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -434,48 +434,39 @@ By using the second parameter you can define a status code for your redirect::
434434
See the :ref:`redirect-component-events` section for how to redirect out of
435435
a life-cycle handler.
436436

437-
Forwarding to an Action on the Same Controller
438-
----------------------------------------------
437+
Loading Additional Tables/Models
438+
================================
439439

440-
.. php:method:: setAction($action, $args...)
440+
.. php:method:: fetchTable(string $alias, array $config = [])
441441
442-
If you need to forward the current action to a different action on the *same*
443-
controller, you can use ``Controller::setAction()`` to update the request
444-
object, modify the view template that will be rendered and forward execution to
445-
the named action::
442+
The ``fetchTable()`` method comes handy when you need to use an ORM table that is not
443+
the controller's default one::
446444

447-
// From a delete action, you can render the updated
448-
// list page.
449-
$this->setAction('index');
445+
// In a controller method.
446+
$recentArticles = $this->fetchTable('Articles')->find('all',
447+
limit: 5,
448+
order: 'Articles.created DESC'
449+
)
450+
->all();
450451

451-
Loading Additional Models
452-
=========================
452+
.. php:method:: fetchModel(string|null $modelClass = null, string|null $modelType = null)
453453
454-
.. php:method:: fetchModel(string $alias, array $config = [])
454+
The ``fetchModel()`` method is useful to load non ORM models or ORM tables that
455+
are not the controller's default::
455456

456-
The ``fetchModel()`` method is useful to load models or ORM tables that
457-
are not the controller's default. Models retrieved with this method will not be
458-
set as properties on your controller::
457+
// ModelAwareTrait need to be explicity added to your controler first for fetchModel() to work.
458+
use ModelAwareTrait;
459459

460460
// Get an ElasticSearch model
461461
$articles = $this->fetchModel('Articles', 'Elastic');
462462

463463
// Get a webservices model
464464
$github = $this->fetchModel('GitHub', 'Webservice');
465465

466-
.. versionadded:: 4.5.0
467-
468-
.. php:method:: fetchTable(string $alias, array $config = [])
469-
470-
The ``fetchTable()`` method comes handy when you need to use an ORM table that is not
471-
the controller's default one::
466+
// If you skip the 2nd argument it will by default try to load a ORM table.
467+
$authors = $this->fetchModel('Authors');
472468

473-
// In a controller method.
474-
$recentArticles = $this->fetchTable('Articles')->find('all',
475-
limit: 5,
476-
order: 'Articles.created DESC'
477-
)
478-
->all();
469+
.. versionadded:: 4.5.0
479470

480471
Paginating a Model
481472
==================

en/controllers/pagination.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ Using a paginator class directly
269269
You can also use a paginator directly.::
270270

271271
// Create a paginator
272-
$paginator = new \Cake\Datasource\Paginator\Paginator();
272+
$paginator = new \Cake\Datasource\Paginator\NumericPaginator();
273273

274274
// Paginate the model
275275
$results = $paginator->paginate(

en/development/dependency-injection.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,15 +292,11 @@ Auto Wiring is turned off by default. To enable it::
292292
// In src/Application.php
293293
public function services(ContainerInterface $container): void
294294
{
295-
$container->add(\Cake\Controller\ComponentRegistry::class);
296295
$container->delegate(
297296
new \League\Container\ReflectionContainer()
298297
);
299298
}
300299

301-
The ``$container->add(\Cake\Controller\ComponentRegistry::class);`` is needed to
302-
fix a cyclic dependency between ``ComponentRegistry`` and ``Controller``.
303-
304300
While your dependencies will now be resolved automatically, this approach will
305301
not cache resolutions which can be detrimental to performance. To enable
306302
caching::

en/development/sessions.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ Session Configuration
1515
Session configuration is generally defined in **/config/app.php**. The available
1616
options are:
1717

18-
* ``Session.timeout`` - The number of *minutes* before CakePHP's session
19-
handler expires the session.
18+
* ``Session.timeout`` - The number of *minutes* a session can remain 'idle'. If
19+
no request is received for ``timeout`` minutes, CakePHP's session
20+
handler will expire the session. You can set this option to ``0`` to disable
21+
server side idle timeouts.
2022

2123
* ``Session.defaults`` - Allows you to use the built-in default session
2224
configurations as a base for your session configuration. See below for the
@@ -49,7 +51,7 @@ this::
4951
]
5052
]);
5153

52-
As of v4.0 CakePHP also sets the `SameSite <https://owasp.org/www-community/SameSite>`__ attribute to ``Lax``
54+
CakePHP also sets the `SameSite <https://owasp.org/www-community/SameSite>`__ attribute to ``Lax``
5355
by default for session cookies, which helps protect against CSRF attacks.
5456
You can change the default value by setting ``session.cookie_samesite`` php.ini config::
5557

@@ -80,8 +82,7 @@ configured using::
8082
Configure::write('Session', [
8183
'defaults' => 'php',
8284
'ini' => [
83-
// Invalidate the cookie after 30 minutes without visiting
84-
// any page on the site.
85+
// Invalidate the cookie after 30 minutes
8586
'session.cookie_lifetime' => 1800
8687
]
8788
]);
@@ -93,7 +94,7 @@ client reports, you should use ``Session.timeout``.
9394

9495
Please note that ``Session.timeout`` corresponds to the total time of
9596
inactivity for a user (i.e. the time without visiting any page where the session
96-
is used), and does not limit the total amount of minutes a user can stay
97+
is used), and does not limit the total amount of minutes a user can stay active
9798
on the site.
9899

99100
Built-in Session Handlers & Configuration

en/development/testing.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,14 +1680,13 @@ correctly by the ``adjust()`` method in our component. We create the file
16801680
public function setUp(): void
16811681
{
16821682
parent::setUp();
1683-
// Setup our component and fake test controller
1683+
// Setup our component and provide it a basic controller.
1684+
// If your component relies on Application features, use AppController.
16841685
$request = new ServerRequest();
16851686
$response = new Response();
1686-
$this->controller = $this->getMockBuilder('Cake\Controller\Controller')
1687-
->setConstructorArgs([$request, $response])
1688-
->setMethods(null)
1689-
->getMock();
1687+
$this->controller = new Controller($request);
16901688
$registry = new ComponentRegistry($this->controller);
1689+
16911690
$this->component = new PagematronComponent($registry);
16921691
$event = new Event('Controller.startup', $this->controller);
16931692
$this->component->startup($event);

en/intro/conventions.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ Entity class names are singular CamelCased and have no suffix. ``User``,
114114
matching the ``users``, ``menu_links`` and ``user_favorite_pages``
115115
tables respectively.
116116

117+
Enum class names should use a ``{Entity}{Column}`` convention, and enum cases
118+
should use CamelCased names.
119+
120+
117121
View Conventions
118122
================
119123

0 commit comments

Comments
 (0)