2.6 Migration Guide
CakePHP 2.6 is a fully API compatible upgrade from 2.5. This page outlines the changes and improvements made in 2.6.
Basics.php
stackTrace()has been added as a convenience wrapper function forDebugger::trace(). It directly echos just asdebug()does. But only if debug level is on.- New i18n functions have been added. The new functions allow you to include message context which allows you disambiguate possibly confusing message strings. For example 'read' can mean multiple things in English depending on the context. The new
__x,__xn,__dx,__dxn,__dxc,__dxcn, and__xcfunctions provide access to the new features.
Cache
RedisEngine
- The
RedisEnginenow has a default prefix ofInflector::slug(APP_DIR).
Console
ConsoleOptionParser
ConsoleOptionParser::removeSubcommand()was added.
Shell
overwrite()has been added to allow generating progress bars or to avoid outputting too many lines by replacing text that has been already outputted to the screen.
Controller
AuthComponent
AuthComponenthad theuserFieldsoption added.- AuthComponent now triggers an
Auth.afterIdentifyevent after a user has been identified and logged in. The event will contain the logged in user as data.
Behavior
AclBehavior
Model::parentNode()now gets the type (Aro, Aco) passed as first argument:$model->parentNode($type).
Datasource
Mysql
- The
RLIKEwildcard operator has been added to allow regular expression pattern lookups this way. - Schema migrations with MySQL now support an
afterkey when adding a column. This key allows you to specify which column the new one should be added after.
Model
Model
Model::save()had theatomicoption back-ported from 3.0.Model::afterFind()now always uses a consistent format for afterFind(). When$primaryis false, the results will always be located under$data[0]['ModelName']. You can set theuseConsistentAfterFindproperty to false on your models to restore the original behavior.
Network
CakeRequest
CakeRequest::param()can now read values using Hash Path Syntax likedata().CakeRequest:setInput()was added.
HttpSocket
HttpSocket::head()was added.- You can now use the
protocoloption to override the specific protocol to use when making a request.
I18n
- Configure value
I18n.preferAppcan now be used to control the order of translations. If set to true it will prefer the app translations over any plugins' ones.
Utility
CakeTime
CakeTime::timeAgoInWords()now supportsstrftime()compatible absolute date formats. This helps make localizing formatted times easier.
Hash
Hash::get()now raises an exception when the path argument is invalid.Hash::nest()now raises an exception when the nesting operation results in no data.
Validation
Validation::betweenhas been deprecated, you should useValidation::lengthBetweeninstead.Validation::ssnhas been deprecated and can be provided as standalone/plugin solution.
View
JsonView
JsonViewnow supports the_jsonOptionsview variable. This allows you to configure the bit-mask options used when generating JSON.
XmlView
XmlViewnow supports the_xmlOptionsview variable. This allows you to configure the options used when generating XML.
Helper
HtmlHelper
HtmlHelper::css()had theonceoption added. It works the same as theonceoption forHtmlHelper::script(). The default value isfalseto maintain backwards compatibility.- The
$confirmMessageargument ofHtmlHelper::link()has been deprecated. You should instead use keyconfirmin$optionsto specify the message.
FormHelper
- The
$confirmMessageargument ofFormHelper::postLink()has been deprecated. You should instead use keyconfirmin$optionsto specify the message. - The
maxlengthattribute will now also be applied to textareas, when the corresponding DB field is of type varchar, as per HTML specs.
PaginatorHelper
PaginatorHelper::meta()has been added to output the meta-links (rel prev/next) for a paginated result set.