Monthly Archives: July 2008

Check your settings while migrating Cake projects

Today I decided to restart the work of a project. The restart includes migration on the other machine as well as updating the Cakephp lib with the final version on the server.

So I copied the whole directory of the project on the second computer /which meant to be the server from now on/ and after this in the cake directory and typed “svn update”. There were some changed files and I received the latest version on the server. So far, so good.

Then I migrated the DB as well, but I decided to follow a new name convention for databases – all database names to follow the full server name i.e. for mydomain.com I would have a mydomain_com /because MySql doesn’t allow dot in the name I replaced dot with underscore/. on the old computer the database was called “mydomain”.

Ok, I changed /app/tmp permission and I decided to see what was the impact of all these actions.

Surprisingly I’ve seen blank screen instead of application screen. I said myself “sh*t, what’s happened? Does the svn update ruin everything? Am I using too old code style?”. Start digging into the code, but whatever I made there wasn’t any change on the screen. Really odd situation. do I found the second “BIG” bug in the cakePHP lib :D, well not true. Here is the explanation.

Finally after 1/2 hour I realized that I’ve changed the name of the database and the old database name doesn’t exist on the server :D. I agree, it’s stupid error and it’s all my fault, but I am wondering why there is no error message telling, that there is no such DB on the server or similar?

I know that on the home.ctp page, which is the default page when you checkout cake from the repository where you can see if the app is connected or not, but what’s happen, when you don’t use this page? Or even as it is in my other project when I rewrite the page controller and I cannot access the default start up page at all?

I think there should be a way which could notify the developers for such stupid “error” or misconfiguration. At lease if the debug level is set to 2 or 3 it should warn I guess.

The dummy mistake while coding

No body is insured from stupid mistakes while writing code. I am not insured, but subscribed for such things. 🙂

Here is the story:
Yesterday, while I was working for a small project I lost 1 hour to detect the stupidest mistake I ever made. Here I will explain what happened and how dummy I fee after that.

I am writing an application where users insert records into the database, and after that on every show of the record, there is a counter field which need to add up the number in it. Simple and easy situation.

While I was working I noticed that only one record /from 5 in the database/ got updates on his counter fields. All other had 0, while I was petty much sure that I’ve seen all these records on the screen. Well, I forced showing the 0 rows but the result was the same. Then I start investigating what could be the problem, but in the database everything was just fine. I deleted all records and started inserting texts /because there are some text fields important in this story/ one by one. Strangely, but again some of the records got update, some not. Finally /by accident/ I noticed, that counter changes when there is a space before or in the end of the value of the text I entered.
Continue reading