NULL problem in GPix admin panel

Latest weeks I got many bug reports about error like this:

Database Error: DB Error: constraint violation(update `mp_settings` set 
`admin_email`='',`html_email`='0',`use_fckeditor`='1', `secret`='jdb314tab518', 
`interlaced_images`='0',`palette_images`='0',`site_down`=NULL, `blog_comments`='0', 
`order_image_galleries`='ksort#SORT_REGULAR',`pixel_list_enable_images`='1' where `id`='1' 
[nativecode=1048 ** Column 'site_down' cannot be null])

this error just "come". Many users don't touch admin settings very long time and got this error when have tried to update settings. After research I discover that problem caused by new MySQL version (5.1). I am not sure if this problem have relation with mysql configuration settings, but it isn't GPix problem with MySQL 5.0 and lower GPix work many years without any notice. Look like MySQL 5.1 don't like definition NULL default 0 and situation when GPix try to update table and don't set value for column with this definition MySQL generate this error.

So, question is how we can solve this? - it is simple

look error message for table and column. In our case

  • mp_settings - it is table name. You can see it in first line of message after word 'update'
  • site_down - is our column and you can see it at the end of message before 'cannot be null'

Now you can build and execute mysql query which will fix this error:

ALTER TABLE `mp_settings` MODIFY `site_down` `site_down` INT NULL DEFAULT 0;

do not forget to replace table name(mp_settings) and column name(site_down - twice)

Execute query like this via phpMyAdmin or mysql console and error will go away.

Trackback URL for this post: