Xaprb

Stay curious!

WordPress and MySQL’s strict mode

with 3 comments

I really don’t like running my database in “I Love Garbage” mode, so I set the following SQL_MODE:

STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO, NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO, NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE, NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY

Guess what WordPress does with that? It doesn’t install. If you set the SQL_MODE to empty and install WordPress, then restore the SQL_MODE, WordPress will run, but if you try to create a post you’ll see an error page that says “You are not allowed to edit this post.”

This problem was reported to WordPress at least 7 years ago. Lessons learned:

  • There is a huge amount of software that was built to work with MySQL 3.23′s irritating habit of inserting different data than you told it to, with nothing but a warning most people will never see.
  • That software will break in unlovely ways when you try to make MySQL behave more correctly.
  • Those who gripe about MySQL’s bugs (as I sometimes do) should remember that MySQL is probably better quality than most of the software that is built to use it. This is probably a universal truth — the Linux kernel is probably better quality than most software that runs in Linux, for example.
  • MySQL’s bugs often get fixed faster than aforementioned software’s bugs, too.

Written by Xaprb

March 15th, 2013 at 2:50 pm

Posted in SQL

3 Responses to 'WordPress and MySQL’s strict mode'

Subscribe to comments with RSS

  1. A philosophical post for Friday evening, but you do make a good and succinct point!

    Henrik Ingo

    15 Mar 13 at 4:28 pm

  2. Roland Bouman

    15 Mar 13 at 6:57 pm

  3. Code quality of WordPress was not something to be proud of, at least in early releases – and security history of the tool is here to prove it.
    I still remember the shock reading a comment whereby “all quotes are transformed into inverted quotes because quotes can not be saved into a database”…

    If you are looking for something which runs on mysql strictest mode, you should probably shop for a sw which can run on 2 or 3 different databases – that forces developers to be careful and learn proper SQL syntax. Otoh it also forces them to throw away most of the goodies that modern databases offer ;-)

    Last words of advice: it’s easy when you work so long and passionately with a product, to see only the warts it has and complain a lot. It is then refreshing to sometimes look around and find out that elsewhere it is actually worse!

    gggeek

    18 Mar 13 at 11:19 am

Leave a Reply