Skip to content

Commit e8964e0

Browse files
committed
Merge branch '5.x' into 5.next
2 parents 56a93c4 + 618610e commit e8964e0

38 files changed

+97
-1544
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,29 @@ ORM
227227
``$this->getSchema()`` inside the ``initialize()`` method.
228228
- ``SaveOptionsBuilder`` has been removed. Use a normal array for options instead.
229229

230+
Known Issues
231+
------------
232+
233+
**Memory usage with large result sets**
234+
235+
Compared to CakePHP 4.x, when working with large data sets (especially when
236+
calling collection methods like ``extract()`` on the result set), you may encounter
237+
high memory usage due to the entire result set being buffered in memory.
238+
239+
You can work around this issue by disabling results buffering for the query::
240+
241+
$results = $articles->find()
242+
->disableBufferedResults()
243+
->all();
244+
245+
Depending on your use case, you may also consider using disabling hydration::
246+
247+
$results = $articles->find()
248+
->disableHydration()
249+
->all();
250+
251+
The above will disable creation of entity objects and return rows as arrays instead.
252+
230253
Routing
231254
-------
232255

en/controllers.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ have called ``Controller::render()``, CakePHP will not try to re-render the view
254254
{
255255
public function my_action()
256256
{
257-
$this->render('custom_file');
257+
return $this->render('custom_file');
258258
}
259259
}
260260

@@ -271,7 +271,7 @@ For example::
271271
{
272272
public function myAction()
273273
{
274-
$this->render('Users.UserDetails/custom_file');
274+
return $this->render('Users.UserDetails/custom_file');
275275
}
276276
}
277277

en/controllers/components.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ as constructor parameters::
190190

191191
class SsoComponent extends Component
192192
{
193+
private Users $users;
194+
193195
public function __construct(
194196
ComponentRegistry $registry,
195197
array $config = [],

en/core-libraries/collections.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ data from paginated services::
265265

266266
$allPagesItems = $items->toList();
267267

268-
If you are using PHP 5.5+, you can use the ``yield`` keyword inside ``unfold()``
269-
to return as many elements for each item in the collection as you may need::
268+
You can use the ``yield`` keyword inside ``unfold()``to return as
269+
many elements for each item in the collection as you may need::
270270
271271
$oddNumbers = [1, 3, 5, 7];
272272
$collection = new Collection($oddNumbers);
@@ -1187,7 +1187,6 @@ Making Collections Rewindable
11871187
The ``buffered()`` method is also useful for converting non-rewindable iterators
11881188
into collections that can be iterated more than once::
11891189

1190-
// In PHP 5.5+
11911190
public function results()
11921191
{
11931192
...

en/core-libraries/time.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ addition of their components::
118118
$time = DateTime::create(2021, 1, 31, 22, 11, 30);
119119
$newTime = $time->subDays(5)
120120
->addHours(-2)
121-
->addMonth(1);
121+
->addMonths(1);
122122
// Outputs '2/26/21, 8:11 PM'
123123
echo $newTime;
124124

@@ -359,7 +359,7 @@ You can also get the date range for a quarter::
359359
$time = new DateTime('2021-01-31');
360360
$range = $time->toQuarterRange();
361361
// Outputs ['2021-01-01', '2021-03-31']
362-
362+
363363
$time = new DateTime('2021-12-25');
364364
$range = $time->toQuarterRange();
365365
// Outputs ['2021-10-01', '2021-12-31']

en/orm/behaviors/tree.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The TreeBehavior helps you maintain a hierarchical data structure in the
1818
database that can be queried without much overhead and helps reconstruct the
1919
tree data for finding and displaying processes.
2020

21+
2122
Requirements
2223
============
2324

@@ -31,6 +32,16 @@ You can configure the name of those fields should you need to customize them.
3132
More information on the meaning of the fields and how they are used can be found
3233
in this article describing the `MPTT logic <https://www.sitepoint.com/hierarchical-data-database-2/>`_
3334

35+
.. warning::
36+
37+
The TreeBehavior is not safe for concurrent write operations.
38+
Simultaneous requests that modify tree-structured data
39+
(e.g., insertions, deletions, or moves) can lead to corruption of the
40+
``lft`` and ``rght`` values.
41+
42+
To prevent this, a locking mechanism like a
43+
`Semaphore <https://www.php.net/manual/en/book.sem.php>`_ should be used.
44+
3445
.. warning::
3546

3647
The TreeBehavior does not support composite primary keys at this point in

en/orm/query-builder.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1881,10 +1881,11 @@ named windows using the ``window()`` method::
18811881
Common Table Expressions
18821882
------------------------
18831883

1884-
Common Table Expressions or CTE are useful when building reporting queries where
1885-
you need to compose the results of several smaller query results together. They
1886-
can serve a similar purpose to database views or subquery results. Common Table
1887-
Expressions differ from derived tables and views in a couple ways:
1884+
`Common Table Expressions or CTE <https://en.wikipedia.org/wiki/Hierarchical_and_recursive_queries_in_SQL#Common_table_expression>`__
1885+
are useful when building reporting queries where you need to compose the results
1886+
of several smaller query results together. They can serve a similar purpose
1887+
to database views or subquery results. Common Table Expressions differ from
1888+
derived tables and views in a couple ways:
18881889

18891890
#. Unlike views, you don't have to maintain schema for common table expressions.
18901891
The schema is implicitly based on the result set of the table expression.

en/orm/retrieving-data-and-resultsets.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,26 @@ The :doc:`/core-libraries/collections` chapter has more detail on what can be
981981
done with result sets using the collections features. The :ref:`format-results`
982982
section show how you can add calculated fields, or replace the result set.
983983

984+
.. warning::
985+
986+
When working with large data sets (especially when calling collection methods
987+
like ``extract()`` on the result set), you may encounter high memory usage
988+
due to the entire result set being buffered in memory.
989+
990+
You can work around this issue by disabling results buffering for the query::
991+
992+
$results = $articles->find()
993+
->disableBufferedResults()
994+
->all();
995+
996+
Depending on your use case, you may also consider using disabling hydration::
997+
998+
$results = $articles->find()
999+
->disableHydration()
1000+
->all();
1001+
1002+
The above will disable creation of entity objects and return rows as arrays instead.
1003+
9841004
Getting the First & Last Record From a ResultSet
9851005
------------------------------------------------
9861006

en/tutorials-and-examples.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ Tutorials & Examples
44
In this section, you can walk through typical CakePHP applications
55
to see how all of the pieces come together.
66

7-
Alternatively, you can refer to the non-official CakePHP plugin repository
8-
`CakePackages <https://plugins.cakephp.org/>`_ and the
9-
`Bakery <https://bakery.cakephp.org/>`_ for existing applications
10-
and components.
11-
127
.. toctree::
138
:maxdepth: 1
149

en/tutorials-and-examples/cms/installation.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ in the **cms** directory of the current working directory:
4545

4646
.. code-block:: console
4747
48-
php composer.phar create-project --prefer-dist cakephp/app:5 cms
48+
php composer.phar create-project cakephp/app:5 cms
4949
5050
If you downloaded and ran the `Composer Windows Installer
5151
<https://getcomposer.org/Composer-Setup.exe>`_, then type the following line in
@@ -54,7 +54,7 @@ C:\\wamp\\www\\dev):
5454

5555
.. code-block:: console
5656
57-
composer self-update && composer create-project --prefer-dist cakephp/app:5.* cms
57+
composer self-update && composer create-project cakephp/app:5.* cms
5858
5959
The advantage to using Composer is that it will automatically complete some
6060
important set up tasks, such as setting the correct file permissions and

0 commit comments

Comments
 (0)