PHP's display_error, not always a good thing!

May
19
2009
Tagged in , &

I just hit an interesting issue while trying to upgrade a Drupal 5.18 site to Drupal 6.12. I went to the update.php page and noticed an error at the top implying the url_alias table was having issues due to Drupal 6 expecting a language column which wasn't present in Drupal 5. "No problem" I thought, "That'll get fixed during the update!". This was the beginning of a long learning curve through the new <a href="http://api.drupal.org/api/group/batch/6">Batch API</a> system!

Whenever I ran the update, it sat there for a minute and eventually display a message to the effect "There was unrecoverable error. See Below for more details" and the details read "An error occurred". This didn't give a lot of clues! So I started debugging and eventually found out the error occurred after system_update_6005.

Why 6005? Well, when the Batch API is started initially, it resets a time counter. It will keep going through it's list of operations (in this case, <a href="http://api.drupal.org/api/function/update_do_one/6">update_do_one</a> for each module/number needing doing) and keeping track of how long this particular round has been going. If the sum of the time for the operations is less than 1 second, then it doesn't bother ending, it does another op (and another, and another… until the sum of the time taken is more than 1 second). Once the 1 second is up, this "round" then it ends and returns a JSON object to the page callback. This page then uses the progress JavaScript system in Drupal to display the animated bar to let you know how it's getting on. The bar updates and then posts back to the site to, essentially, say "you may now continue from where you left off" and the next round starts. This keeps going until the operations array is empty.

Remember earlier, I said I had display_errors enabled (a common practice for a development environment)… Well when the JSON object got returned, there ws a non-JSON line tagged at the top which was meant to be there to tell me about the MySQL error caused by the broken url_alias table. The JavaScript JSON engine didn't like that so threw the error message. This is also why, if I restarted the updates, they worked fine.

So… Debugging… Not always a good thing!

Comment Icon

1 Comments

The most recent comment was on Wed, 20th May 2009, 14:23

hmmm

sounds like a bug to me. I suppose you don't really want things to continue if there's a fatal PHP error, but maybe there should be some sort of check done before update_do_one is called.

Follow Me

Recent comments

ed hardy 11 hours ago
Replies.... 4 days ago
Or in 4 days ago
A few tweaks 5 days ago
Nice 5 days ago
Thanks a million 1 week ago
Syndicate content