What Is New in CakePHP 2.6
CakePHP 2.6 is an iterative release focusing on enhancements, security, and bug fixes. It introduces several new features and deprecates some older functionality to prepare for the future. The table below summarizes the key changes.
| Category | Key Changes |
|---|---|
| New Features | New Model::validateAssociated() method, Hash::merge() behavior change,
Cache::engine() improvements. |
| Improvements | Better session handling, enhanced Security::cipher(), updated HttpSocket
and CakeEmail. |
| Bug Fixes | Fixes across FormHelper, Routing, Console, and Model behaviors. |
| Security | Session fixation protection is now enabled by default. |
| Deprecated | Controller::$modelClass, View::loadHelpers(), and several methods in
Security and Utility classes. |
What are the new utility and model methods?
The Hash::merge() method now performs a recursive merge for numeric indexed arrays, which is more
intuitive for combining dataset-like structures. In practice, this means merging arrays with numeric keys won't
overwrite previous values as it did before.
A new model method, Model::validateAssociated(), allows you to validate multiple model associations
at once. This is useful for complex data saves where you need to check the validity of related data before
proceeding with the main save operation.
How is session security improved?
Session fixation protection is now turned on by default. This changes the session ID upon login, preventing attacks where an attacker sets a user's session ID. You must ensure your session configuration does not use a native PHP session handler that lacks this feature.
The Security::cipher() method was updated to use an improved encryption algorithm. If you were
relying on the old cipher for custom encryption, you'll need to re-encrypt your data or override the method to
maintain compatibility.
What helpers and components were updated?
The FormHelper received fixes for generating HTML5 validation attributes and handling multiple
checkboxes. These fixes make form generation more consistent with modern browser standards.
Cache::engine() can now be called statically from any scope, making cache configuration access more
flexible. The HttpSocket and CakeEmail classes saw updates for better protocol
handling and header management.
What functionality is now deprecated?
Several elements are marked for removal in future versions. Controller::$modelClass is deprecated in
favor of using $this->ModelName directly. The View::loadHelpers() method is
deprecated; helpers should be loaded via the $helpers array.
Methods like Security::hash() with the 'sha1' or 'md5' algorithms and String::uuid()
are also deprecated. You should update to use the newer, more secure alternatives provided by the framework.
FAQ
What is the most critical change in CakePHP 2.6 for security?
The default enabling of session
fixation protection. If your application uses a custom session handler that doesn't support ID regeneration, you
must test your login flow thoroughly.
I use Hash::merge() extensively. Will my application break?
It might if you depend on the old
non-recursive merging of numeric arrays. Test areas where you merge indexed arrays, as the output structure will
now be different.
How do I replace the deprecated Controller::$modelClass?
Use the model's name directly. For
example, if you had $this->modelClass = 'Post';, you should now access the model via
$this->Post within your controller.
Is there a new recommended way to generate UUIDs?
Yes, the String::uuid() method
is deprecated. Use CakeText::uuid() instead, which provides the same functionality from a renamed
class.
Should I update my encryption data because of the Security::cipher() change?
Only if you were
using Security::cipher() directly for your own encryption/decryption logic. The core framework
usage is handled internally, but custom implementations need to adapt.