Catalyst, MySQL, SQLite, H::FH, UTF-8 and more

I tried to update an online website with some changes. Generally, I run a production and a testing environment. Recently, however, I moved the code from using SQLite to MySQL and did not create a testing DB, so changes that require changing the text on the site are done in production. Not good? I know!

So the website is built in Catalyst. Originally used SQLite and then migrated to MySQL (which had to be done manually). It uses HTML::FormHandler to display the forms, with a generic CRUD layer I added.

When trying to load the form, I get weird characters for some of the page. From what I gathered, the data in the MySQL isn't kept in UTF8 but in latin1 but we declare the page as UTF8 encoding. The form isn't displayed in utf8 (which was changed using "use utf8;" in the form .pm file, or using Encode::Guess which yielded a better result). David Wheeler has a really interesting article on UTF8 in Perl here.

When that didn't work, I decided to convert the entire database to UTF-8. I read it using pure DBI, and using DBIC and explicit utf8 column declaration I inserted each table to a newly create database where the tables are charset UTF-8 with utf-8 collation. That didn't change anything. Apparently the latin1 was fine.

More investigation revealed that the HTML::FormHandler::Render::Simple was decoding some stuff which was screwing up a lot. Once that was fixed (AKA patching it up), more stuff remained unclear. It was as if H::FH wasn't able to read the correct record from the database. Trying to do it using $c->model('DB::Table')->search( { id => $id } ) worked just fine. Apparently the API in HTML::FormHandler changed or it has a critical bug.

I should read the manual. There is the manual, tutorial and an intro for it. They are all very very long and complex. They give me a headache. Honestly, I'm more comfortable reading the Perl XS tutorial rather than the current synopsis or ANY documentation of HTML::FormHandler.

Alas, I'll have to get rid of HTML::FormHandler. It's become so cumbersome I can't be bothered patching it any more even. I don't want to reinvent the form wheel again (because I probably won't put a lot into it). Maybe I'll add a layer on top of FormFu.

I remember asking mst about forms in #catalyst a long while ago. He said that "forms suck.. some people find FormFu helps make them suck less." I think I understand it better now.


If you are able to reproduce an H::FH bug in an isolated test case (i.e. outside your application), I'm sure the author would work on supplying a fix. I dropped by in the #formhandler IRC channel (see the SUPPORT section of the docs) the other day after discovering a bug and the author dropped a new release on the CPAN within a day or two, fixing the bug.

There's usually help out their if you take the time to find it that will help you figure out what's wrong...

Check it out with the kind folks at #formhandler, I'm sure there's someone there who can help you.

Leave a comment

About Sawyer X

user-pic Gots to do the bloggingz