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 
site_name`='XXXX',`site_description`='YYYY',`currency_symbol`='$',`user_accounts`='1',`approval_required`='0', 
`admin_email`='manager@example.com',`html_email`='0',`use_fckeditor`='1', `secret`='jdb314tab518', 
`interlaced_images`='0',`palette_images`='0',`site_down`=NULL, `blog_comments`='0', 
`expires_check_at`=NULL,`multiple_grid_pages`='1',`grid_columns`='1',`rss_latest_pixels`='10',`rss_top_pixels`='10', 
`rss_blog_articles`='0',`pixel_list_by_clicks`='0',`seo_status`='optimized',`link_to_us_enabled`=NULL,`upload_images`='1', 
`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:

https://www.kalexandr.com/trackback/37
Tags:
Links: