diff --git a/en/appendices/5-2-migration-guide.rst b/en/appendices/5-2-migration-guide.rst index 57b11b0001..1cd9b80909 100644 --- a/en/appendices/5-2-migration-guide.rst +++ b/en/appendices/5-2-migration-guide.rst @@ -15,6 +15,13 @@ Behavior Changes New Features ============ +ORM +--- + +- ``CounterCacheBehavior::updateCounterCache()`` has been addded. This method + allows you to update the counter cache values for all records of the configured + associations. + Error ----- diff --git a/en/orm/behaviors/counter-cache.rst b/en/orm/behaviors/counter-cache.rst index ae87db1142..5f18715456 100644 --- a/en/orm/behaviors/counter-cache.rst +++ b/en/orm/behaviors/counter-cache.rst @@ -162,3 +162,19 @@ with the same code as described above.:: ]); Finally clear all caches with ``bin/cake cache clear_all`` and try it out. + +Updating all counter caches +=========================== + +.. php:method:: updateCounterCache(?string $assocName = null, int $limit = 100, ?int $page = null): void + +The ``updateCounterCache()`` method allows you to update the counter cache values +for one or all configured associations in batches. This can be useful, for example, +to update the counter cache after importing data directly into the database. + +.. versionadded:: 5.2.0 + +.. note:: + + This methods won't update the counter cache values for fields which are + configured to use a closure to get the count value.