Skip to content

Commit 9ab93c0

Browse files
committed
Merge branch '5.next' into 5.x
2 parents c85c94d + 260d99a commit 9ab93c0

File tree

23 files changed

+430
-35
lines changed

23 files changed

+430
-35
lines changed

config/conf.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
# built documents.
1111
#
1212
# The short X.Y version.
13-
version = '5.x'
13+
version = '5.next'
1414

1515
# The full version, including alpha/beta/rc tags.
16-
release = '5.x'
16+
release = '5.next'
1717

1818
# The search index version.
19-
search_version = '5'
19+
search_version = '5-next'
2020

2121
# The marketing diplay name for the book.
2222
version_name = 'Chiffon'
@@ -32,14 +32,14 @@
3232
{'name': '1.1', 'number': '1.1', 'title': '1.1 Book'},
3333
]
3434
# Enables the 'development version banner'
35-
is_prerelease = False
35+
is_prerelease = True
3636

3737
# Languages available.
3838
languages = ['en', 'pt_BR', 'es', 'ja', 'fr']
3939

4040
# The GitHub branch name for this version of the docs
4141
# for edit links to point at.
42-
branch = '5.x'
42+
branch = '5.next'
4343

4444
# Add any paths that contain custom themes here, relative to this directory.
4545
html_theme_path = []

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

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
5.2 Migration Guide
2+
###################
3+
4+
The 5.2.0 release is a backwards compatible with 5.0. It adds new functionality
5+
and introduces new deprecations. Any functionality deprecated in 5.x will be
6+
removed in 6.0.0.
7+
8+
Behavior Changes
9+
================
10+
11+
- ``ValidationSet::add()`` will now raise errors when a rule is added with
12+
a name that is already defined. This change aims to prevent rules from being
13+
overwritten by accident.
14+
- ``Http\Session`` will now raise an exception when an invalid session preset is
15+
used.
16+
- ``FormProtectionComponent`` now raises ``Cake\Controller\Exception\FormProtectionException``. This
17+
class is a subclass of ``BadRequestException``, and offers the benefit of
18+
being filterable from logging.
19+
- ``NumericPaginator::paginate()`` now uses the ``finder`` option even when a ``SelectQuery`` instance is passed to it.
20+
21+
Deprecations
22+
============
23+
24+
Console
25+
-------
26+
27+
- ``Arguments::getMultipleOption()`` is deprecated. Use ``getArrayOption()``
28+
instead.
29+
30+
Datasource
31+
----------
32+
33+
- The ability to cast an ``EntityInterface`` instance to string has been deprecated.
34+
You should ``json_encode()`` the entity instead.
35+
36+
- Mass assigning multiple entity fields using ``EntityInterface::set()`` is deprecated.
37+
Use ``EntityInterface::patch()`` instead. For e.g. change usage like
38+
``$entity->set(['field1' => 'value1', 'field2' => 'value2'])`` to
39+
``$entity->patch(['field1' => 'value1', 'field2' => 'value2'])``.
40+
41+
Event
42+
-----
43+
44+
- Returning values from event listeners / callbacks is deprecated. Use ``$event->setResult()``
45+
instead or ``$event->stopPropogation()`` to just stop the event propogation.
46+
47+
View
48+
----
49+
50+
- The ``errorClass`` option of ``FormHelper`` has been deprecated in favour of
51+
using a template string. To upgrade move your ``errorClass`` definition to
52+
a template set. See :ref:`customizing-templates`.
53+
54+
55+
New Features
56+
============
57+
58+
Console
59+
-------
60+
61+
- The ``cake counter_cache`` command was added. This command can be used to
62+
regenerate counters for models that use ``CounterCacheBehavior``.
63+
- ``ConsoleIntegrationTestTrait::debugOutput()`` makes it easier to debug
64+
integration tests for console commands.
65+
- ``ConsoleInputArgument`` now supports a ``separator`` option. This option
66+
allows positional arguments to be delimited with a character sequence like
67+
``,``. CakePHP will split the positional argument into an array when arguments
68+
are parsed.
69+
- ``Arguments::getArrayArgumentAt()``, and ``Arguments::getArrayArgument()``
70+
were added. These methods allow you to read ``separator`` delimitered
71+
positional arguments as arrays.
72+
- ``ConsoleInputOption`` now supports a ``separator`` option. This option
73+
allows option values to be delimited with a character sequence like
74+
``,``. CakePHP will split the option value into an array when arguments
75+
are parsed.
76+
- ``Arguments::getArrayArgumentAt()``, ``Arguments::getArrayArgument()``, and
77+
``Arguments::getArrayOption()``
78+
were added. These methods allow you to read ``separator`` delimitered
79+
positional arguments as arrays.
80+
81+
Database
82+
--------
83+
84+
- The ``nativeuuid`` type was added. This type enables ``uuid`` columns to be
85+
used in Mysql connections with MariaDB. In all other drivers, ``nativeuuid``
86+
is an alias for ``uuid``.
87+
- ``Cake\Database\Type\JsonType::setDecodingOptions()`` was added. This method
88+
lets you define the value for the ``$flags`` argument of ``json_decode()``.
89+
- ``CounterCacheBehavior::updateCounterCache()`` was added. This method allows
90+
you to update the counter cache values for all records of the configured
91+
associations. ``CounterCacheCommand`` was also added to do the same through the
92+
console.
93+
- ``Cake\Database\Driver::quote()`` was added. This method provides a way to
94+
quote values to be used in SQL queries where prepared statements cannot be
95+
used.
96+
97+
Datasource
98+
----------
99+
100+
- Application rules can now use ``Closure`` to define the validation message.
101+
This allows you to create dynamic validation messages based on the entity
102+
state and validation rule options.
103+
104+
Error
105+
-----
106+
107+
- Custom exceptions can have specific error handling logic defined in
108+
``ErrorController``.
109+
110+
ORM
111+
---
112+
113+
- ``CounterCacheBehavior::updateCounterCache()`` has been added. This method
114+
allows you to update the counter cache values for all records of the configured
115+
associations.
116+
- ``BelongsToMany::setJunctionProperty()`` and ``getJunctionProperty()`` were
117+
added. These methods allow you to customize the ``_joinData`` property that is
118+
used to hydrate junction table records.
119+
- ``Table::findOrCreate()`` now accepts an array as second argument to directly pass data in.
120+
121+
TestSuite
122+
---------
123+
124+
- ``TestFixture::$strictFields`` was added. Enabling this property will make
125+
fixtures raise an error if a fixture's record list contains fields that do not
126+
exist in the schema.
127+
128+
View
129+
----
130+
131+
- ``FormHelper::deleteLink()`` has been added as convenience wrapper for delete links in
132+
templates using ``DELETE`` method.
133+
- ``HtmlHelper::importmap()`` was added. This method allows you to define
134+
import maps for your JavaScript files.
135+
- ``FormHelper`` now uses the ``containerClass`` template to apply a class to
136+
the form control div. The default value is ``input``.
137+

en/appendices/migration-guides.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ each version and the migration path between 5.x minor releases.
1010
./5-0-upgrade-guide
1111
./5-0-migration-guide
1212
./5-1-migration-guide
13+
./5-2-migration-guide
1314
./phpunit10

en/console-commands.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ CakePHP Provided Commands
145145

146146
console-commands/cache
147147
console-commands/completion
148+
console-commands/counter-cache
148149
console-commands/i18n
149150
console-commands/plugin
150151
console-commands/schema-cache

en/console-commands/commands.rst

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,6 @@ To get started testing your console application, create a test case that uses th
298298
``exec()`` that is used to execute your command. You can pass the same string
299299
you would use in the CLI to this method.
300300

301-
.. note::
302-
303-
For CakePHP 4.4 onwards the ``Cake\Console\TestSuite\ConsoleIntegrationTestTrait`` namespace should be used.
304-
305301
Let's start with a very simple command, located in
306302
**src/Command/UpdateTableCommand.php**::
307303

@@ -549,6 +545,20 @@ assertion methods that make help assert against console output::
549545
// assert that stderr matches a regular expression
550546
$this->assertErrorRegExp($expected);
551547

548+
Debug Helpers
549+
-------------
550+
551+
You can use ``debugOutput()`` to output the exit code, stdout and stderr of the
552+
last run command::
553+
554+
$this->exec('update_table Users');
555+
$this->assertExitCode(Command::CODE_SUCCESS);
556+
$this->debugOutput();
557+
558+
.. versionadded:: 4.2.0
559+
The ``debugOutput()`` method was added.
560+
561+
552562
Lifecycle Callbacks
553563
===================
554564

en/console-commands/counter-cache.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
CounterCache Tool
2+
#################
3+
4+
The CounterCacheCommand provides a CLI tool for rebuilding the counter caches
5+
in your application and plugin models. It can be used in maintenance and
6+
recovery operations, or to populate new counter caches added to your
7+
application.
8+
9+
.. code-block:: console
10+
11+
bin/cake counter_cache --assoc Comments Articles
12+
13+
This would rebuild the ``Comments`` related counters on the ``Articles`` table.
14+
For very large tables you may need to rebuild counters in batches. You can use
15+
the ``--limit`` and ``--page`` options to incrementally rebuild counter state.
16+
17+
.. code-block:: console
18+
19+
bin/cake counter_cache --assoc Comments --limit 100 --page 2 Articles
20+
21+
When ``limit`` and ``page`` are used, records will be ordered by the table's
22+
primary key.
23+
24+
.. versionadded:: 5.2.0

en/console-commands/option-parsers.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,16 @@ You can use the following options when creating an argument:
5959
* ``choices`` An array of valid choices for this argument. If left empty all
6060
values are valid. An exception will be raised when parse() encounters an
6161
invalid value.
62+
* ``separator`` A character sequence that separates arguments that should be
63+
parsed into an array.
6264

6365
Arguments that have been marked as required will throw an exception when
6466
parsing the command if they have been omitted. So you don't have to
6567
handle that in your shell.
6668

69+
.. versionadded:: 5.2.0
70+
The ``separator`` option was added.
71+
6772
Adding Multiple Arguments
6873
-------------------------
6974

@@ -140,10 +145,16 @@ of the option:
140145
Defaults to ``false``.
141146
* ``multiple`` - The option can be provided multiple times. The parsed option
142147
will be an array of values when this option is enabled.
148+
* ``separator`` - A character sequence that the option value is split into an
149+
array with.
143150
* ``choices`` - An array of valid choices for this option. If left empty all
144151
values are valid. An exception will be raised when parse() encounters an
145152
invalid value.
146153

154+
155+
.. versionadded:: 5.2.0
156+
The ``separator`` option was added.
157+
147158
Adding Multiple Options
148159
-----------------------
149160

en/console-commands/schema-cache.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Schema Cache Tool
22
#################
33

4-
The SchemaCacheShell provides a simple CLI tool for managing your application's
4+
The SchemaCacheCommand provides a simple CLI tool for managing your application's
55
metadata caches. In deployment situations it is helpful to rebuild the metadata
66
cache in-place without clearing the existing cache data. You can do this by
77
running:

en/controllers/components/form-protection.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,16 @@ configuration option to a callback function in the controller.
146146
By configuring a callback method you can customize how the failure handling process
147147
works::
148148

149+
use Cake\Controller\Exception\FormProtectionException;
150+
149151
public function beforeFilter(EventInterface $event)
150152
{
151153
parent::beforeFilter($event);
152154

153155
$this->FormProtection->setConfig(
154156
'validationFailureCallback',
155-
function (BadRequestException $exception) {
157+
// Prior to 5.2 use Cake\Http\Exception\BadRequestException.
158+
function (FormProtectionException $exception) {
156159
// You can either return a response instance or throw the exception
157160
// received as argument.
158161
}

en/development/errors.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,30 @@ prefix. You could create the following class::
210210
This controller would only be used when an error is encountered in a prefixed
211211
controller, and allows you to define prefix specific logic/templates as needed.
212212

213+
Exception specific logic
214+
------------------------
215+
216+
Within your controller you can define public methods to handle custom
217+
application errors. For example a ``MissingWidgetException`` would be handled by
218+
a ``missingWidget()`` controller method, and CakePHP would use
219+
``templates/Error/missing_widget.php`` as the template. For example::
220+
221+
namespace App\Controller\Admin;
222+
223+
use App\Controller\AppController;
224+
use Cake\Event\EventInterface;
225+
226+
class ErrorController extends AppController
227+
{
228+
protected function missingWidget(MissingWidgetException $error)
229+
{
230+
// You can prepare additional template context or trap errors.
231+
}
232+
}
233+
234+
.. versionadded:: 5.2.0
235+
Exception specific controller methods and templates were added.
236+
213237
.. _custom-exceptionrenderer:
214238

215239
Custom ExceptionRenderer

0 commit comments

Comments
 (0)