Updating to Cake 1.3

Last night I updated this site to run on the latest 1.3 build. While I know I should have done it earlier, I simply haven’t had the time. And since I went through it, I figured I could document it and share what the upgrade process is like for a small site, that doesn’t see a ton of maintenance action like this one.

Basics first

Of course the first thing I did was read the migration guide to checkout what might be needed to be done. And since 1.3 is still a work in progress I’ll make sure I check there each time I update from the repository. The first thing I had to do was update my webroot/index.php as things have changed there.

Things to fix

First thing I had to do was replace both app/webroot/index.php and app/webroot/test.php as some of their internals have changed a bit. Next up was a missing error from CakeSocket which was easily fixed by copying and pasting the new import from the migration guide. Next I had used some of the old validation constants like VALID_NOT_EMPTY, those constants have been removed for 1.3 and I had to use the co-responding Validation method names. Following that, I had used the old $escapeTitle parameter on several links so those needed to be updated to use the escape attribute. Since I had originally built this site against 1.2 beta, there were several uses of the old findAll method, which was removed in 1.3 in favor of only having find('all'). I had also been a bit cheeky with some of my request parameter checking. I had done things like

Show Plain Text
  1. if (isset($this->params[Configure::read('Routing.admin')]) && $this->Auth->user()) {
  2.     ...
  3. }

Which doesn’t work after you update Routing.admin to 1.3’s Routing.prefixes. Instead my check just uses the 'admin' string literal. I had also use a few deprecated methods like Model::del() but after running my unit tests and seeing errors spew down the test runner I knew what had to be fixed.

Things to clean up

While the change to 1.3 caused a few issues, it also let me simplify and reduce the code used in a few places. For example I was able to remove $paginator->options(array('url' => $this->passedArgs)); as it is done automatically now in 1.3.

Overall the process took me approximately 2 hours including writing this post while I was doing the updates. I think it was a fairly painless process and hope that when you take the dive to update to 1.3 you find it easier than the transition from 1.1 to 1.2 was.

Comments

I also upgraded to Cake 1.3. Great work. I’m having an issue with 1.3 and it seems like its happening on your blog as well.

If I download Cake 1.3 from the cakephp.org website, that version comes with a bug where debug = 0 still shows missing controller errors, etc.

If I download the latest 1.3 from Github, it comes with a bug where $this->set(‘title_for_layout’, ‘My title’) doesn’t work. And it looks like that is also happening on your blog as well. The page titles are defaulting to the controller name.

Dan on 12/24/09

Dan: I actually forgot to update the page titles when I updated, but I used $this->set('title_for_layout', $value); in the view files and everything is working fine. As for the missing controller errors, I don’t see them when visiting incorrect urls on this site. There was an issue in 1.3 related to that, but its been fixed.

mark story on 12/31/09

I see what was wrong. I was trying to call $this->set(‘title_for_layout’, $value); from the controller :/

Thanks for the heads up. I’m looking forward to 1.3. Keep up the good work.

Dan on 1/7/10

hi, please help me. I can’t see how to change something like this:
if (isset($this->params[Configure::read(‘Routing.admin’)])

into the new cakephp 1.3 way.
can you tell me how you did it?

sorry for my english…

Hector on 6/11/10

Hi,

I have the same question as Hector. I’ve been trying to figure out how to determine if the admin prefix routing is in effect but since I can’t use Configure::read(‘Routing.admin’)], I’m kinda lost.

Your post says “Instead my check just uses the ‘admin’ string literal.” Would you care to give an example?

Thank you.

Simon on 7/13/10

Simon: Sure

if (isset($this->params['admin'])) {
   //do admin stuff
}

Thats about it :)

mark story on 7/18/10

thanks!!!

Hector on 9/29/10

Thank you Mark! :)

Simon on 9/30/10

see also that the

echo $cakedebug;

on default.ctp or on each of yours layouts ctp , is replaced now by:

echo $this->element(‘sql_dump’);

—-

papachan on 10/4/10

And for contact forms, you must use

$form->inputs( array(.. list yours inputs here ));

instead of

$form->input();

—-

papachan on 10/4/10

Comments are not open at this time.