|
| 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 | + |
0 commit comments