Deprecated stuff in CakePHP 1.2
Yesterday I got asked by Beth in a comment whether there is a list of deprecated stuff. As I am not aware of such a list I compiled one by searching for the term “deprecated” in the cake folder of CakePHP 1.2beta. You find the results below. Most of the deprecated stuff still works, but some of it will show you a notice when used during development (when debug > 0). It is recommended to no longer use the deprecated stuff, as it is possible it will be removed in future releases. Ok, here we go:
On the console the command
cake acl initdb
has been replaced by
cake schema run create DbAcl
In basics.php all load functions have been replaced by App::import(): loadView(), loadModel(), loadController(), loadHelper(), loadPluginHelper(), loadComponent(), loadPluginComponent(), loadBehavior(), loadModels(), loadPluginModels(), and loadControllers().
The function listClasses() has been replaced by Configure::listObjects(), and the implementations of setUri() and setUrl() have been moved to the dispacher and are now called uri() resp. getUrl().
The initialization of the cookie component has changed, it should be configured in the beforeFilter of the controller and therefore the initialize() method should no longer be used.
The implementation of cleanUpFields() has been moved from the controller to Model::deconstruct().
In the model two methods are deprecated: loadInfo() has been replaced by Model::schema() and generateList() by Model::find(’list’). Also the parameter usage of validates() and invalidFields() has been deprecated, you have to set the $data property instead.
In the form helper the method submitImage() should no longer be used, instead the submit() method can be used.
As there is the form helper for creating form elements, all form-related methods in the HTML helper are deprecated: radio(), password(), textarea(), checkbox(), hidden(), input(), tagValue(), validate(), validateErrors(), and tagErrorMsg().
In the Javascript helper the $safe parameter for the codeBlock() method, plus the parameters $prefix, $postfix, $stringKeys, $quoteKeys, and $q for object() are deprecated.
In the helper class the method setFormTag() has been replaced by setEntity().
The properties $themeElement, $themeLayout, and $themePath are no longer needed in the theme class.
In the file class many methods have been renamed, and therefore the old names are deprecated: getFullPath(), getName(), fileName(), getExt(), getMd5(), getSize(), getOwner(), getGroup(), getChmod(), and getFolder().
The functionality of chmodr() and mkdirr() from the folder class is now handled by chmod() resp. mkdir().
In the router the routes for web services are deprecated: “/rest/”, “/rss/”, “/soap/”, “/xml/”, and “/xmlrpc/”. The same is true for the routes “/bare/” and “/ajax/”.
Last, but not least, the validation constants VALID_NOT_EMPTY, VALID_NUMBER, VALID_EMAIL, and VALID_YEAR are deprecated.




You’re the MAN!!!
Thanks so much for taking the time collecting and posting this. It goes a long way in helping us mere mortals :)
Found this Deprecated List from API http://api.cakephp.org/1.2/deprecated.html
@Beth, phpsc: Thanks for your comments!
@phpsc: Thanks for the link, I wasn’t aware there exists such a page in the API.
Model::generateList() deprecated, use Model::find(’list’)
r6360 commit introduced a way to do custom fields
Model::find(’list’, array(’fields’ => array(’Model.id’, ‘Model.custom_name’))
Now that is beautiful API
@speedmax: Yes, it is nice, even though it is probably more difficult to use it (without documentation).
[...] lainnya, setelah browsing sana-sini akhirnya ketemu juga dengan daftar deprecated stuff di blognya CakeBaker, jika anda sedang belajar CakePHP 1.2 mungkin daftar ini bisa jadi pertimbangan, soalnya beberapa [...]
[...] with the new functionalities are the deprecated ones. Check out the Deprecated Stuff in CakePHP 1.2 for a list of the deprecated items. Although these stuffs still work, they are not recommended for [...]
I might be missing something, but the new method for generating lists is not as good. My issue is that, previously with generateList, both the ID and display name could be specified. Now in 1.2, only the display name can be specified, and the primary key is assumed as the ID. I looked through the model.php code as well, and it looks like there’s no value that can be passed in to overwrite this.
If anyone sees a solution for this, I would be very grateful for your help!
Oops, I missed speedmax’s response. That should solve my problems, I’ll check it out!
Thank you. Your blog kicks ass.
[...] cakebaker.42dh.com - Deprecated stuff in CakePHP 1.2 [...]
@JDS: Thanks!
i’ve try
Model::find(’list’, array(’fields’ => array(’Model.id’, ‘Model.custom_name’))
but it returned array (’id’='id’) instead (’id’=>’custom_name’)
:(
@marcin: Hm, which CakePHP version do you use?
i should convert $this->Company->generateList() to $this->Company->find(’list’); for 1.2 as generateList is depricated. But how can i convert $this->Company->generateList(null,null,null,null,’{n}.Company.company_name’); ?
@KireZ: Something like
$this->Company->find('list', array('fields' => array('Company.company_name')));should do the trick.
Hope that helps!
how can i convert this:
$this->set(’Cat_List’,$this->Ad->Cat->generateList(null, ‘name_de ASC’, null, ‘{n}.Cat.id’, ‘{n}.Cat.name_de’));
if i convert it as below:
$this->set(’Cat_List’,$this->Ad->Cat->find(’list’,array(’order’=>’name_de ASC’,'fields’=>array(’{n}.Cat.id’,'{n}.Cat.name_de’)))));
it only returned me:
array (’id’=’id’) instead (’id’=>’name_de’)
@yunhaihuang: Hm, your example with find causes an error here (I’m using the latest version from the repository). If I remove the “{n}” from the fields array, then I get id/name_de pairs as result.
Hope that helps!
Thanks a lot for the information, I have to migrate from 1.1 to 1.2, and this information will be VERY usefull. Thx!!!!!
@Pablo: Good luck with your migration!
Thanks for your help! But it’s work as i expect, althought i remove the ‘{n}’(i’m using cakephp beta). with best wishes!
i’m sorry about my mistake.
it doesn’t work as i expect, althought i removed the ‘{n}’.
please help me overcome this error.
i’m sorry about my mistake.
it doesn’t work as i expect, althought i removed the ‘{n}’.
please help me overcome this situation.
@yunhaihuang: What doesn’t work? Can you give an example of what you try and what you expect?
i want it return a list (cat.id/cat.name_de), but it only return me a list with cat.id
@yunhaihuang: Set debug to 2 (in app/config/core.php) and look what SQL code cake generates. Maybe you can then figure out what’s going wrong…
If not, which cake version do you use?