-
Notifications
You must be signed in to change notification settings - Fork 142
Included fixes and migration tweaks
The Tools plugin not only contains quite a few useful tools, as one expects. It also provides some bugfixes and migration help regarding major version jumps that cannot be provided by the framework itself that easily. Mainly due to BC (backwards compatibility) some methods and default values as well as buggy code needs to be the way it is. Also, to provide a less painful upgrade to the next major version it might already provide some of the new functionality and with that allows moving away earlier from deprecated or less ideal ways of coding.
-
Auto-trim on POST (to make "notEmpty" validation work properly) when adding the Common Component.
-
Provided a less error-prone inArray() method when using Utility class.
-
trigger_error('AppModel instance! Expected: ' . $this->name);
warning if plugin models are used/included incorrectly when using MyModel. -
Fix for non atomic queries (MyISAM etc) and saveAll to still return just the boolean result when using MyModel.
-
Don't log 404s and other "non-errors" to the errors log:
// core.php App::uses('MyErrorHandler', 'Tools.Error'); Configure::write('Error', array( 'handler' => 'MyErrorHandler::handleError', 'level' => E_ALL & ~E_DEPRECATED, 'trace' => true )); Configure::write('Exception', array( 'handler' => 'MyErrorHandler::handleException', 'renderer' => 'Tools.MyExceptionRenderer', 'log' => true ));
-
Auto-aliasing for models' "order" properties when using MyModel.
-
Disable cache also works for older IE versions when using MyController.
-
public $recursive = -1;
and Containable for all models when using MyModel. -
testAction defaults to GET now:
App::uses('MyControllerTestCase', 'Tools.TestSuite'); class UsersControllerTest extends MyControllerTestCase {}
-
MyModel::get() replaces any Model::read() call and is as close to the 3.x method as possible (which will also be Table::get():
// My 2.x get() public function get($primaryKey, array $options = array()) {} // And in 3.x then public function get($primaryKey, $options = []) {
This will make upgrading those method calls easy. And read() should not be used anyway.
-
Default pagination config can be set DRY using Configure key "Paginator" when using controller's paginate() method. But you can also just have this in your AppController's beforeFilter() method:
$this->paginate['paramType'] = 'querystring';
-
Get a warning if you forgot to remove/upgrade any named params to query strings when using the CommonComponent and enabling Configure key
'App.warnAboutNamedParams'
. More infos here.
Also don't forget to have a peak into the Upgrade plugin Wiki.