mirror of https://github.com/BOINC/boinc.git
web: changes to support MySQL strict mode
In "strict mode", inserts fail if they don't supply values for columns with no default defined in the schema (in non-strict mode, 0 and '' are implicit defaults). Starting with MySQL version 5.6, strict mode is the default. This breaks some of the BOINC web code, which does inserts without giving values to some columns. There are two ways to solve this: 1) change the schema to give defaults everywhere 2) change the PHP code to supply values for more columns. I'm using 1) in some cases and 2) in others. This commit fixes some of the errors; there are others.
This commit is contained in:
parent
c3efe4fe44
commit
7a00aa4976
|
@ -443,18 +443,18 @@ create table forum (
|
|||
orderID integer not null,
|
||||
title varchar(254) not null,
|
||||
description varchar(254) not null,
|
||||
timestamp integer not null,
|
||||
timestamp integer not null default 0,
|
||||
-- time of last new or modified thread or post
|
||||
threads integer not null,
|
||||
threads integer not null default 0,
|
||||
-- number of non-hidden threads in forum
|
||||
posts integer not null,
|
||||
rate_min_expavg_credit integer not null,
|
||||
rate_min_total_credit integer not null,
|
||||
post_min_interval integer not null,
|
||||
post_min_expavg_credit integer not null,
|
||||
post_min_total_credit integer not null,
|
||||
posts integer not null default 0,
|
||||
rate_min_expavg_credit integer not null default 0,
|
||||
rate_min_total_credit integer not null default 0,
|
||||
post_min_interval integer not null default 0,
|
||||
post_min_expavg_credit integer not null default 0,
|
||||
post_min_total_credit integer not null default 0,
|
||||
is_dev_blog tinyint not null default 0,
|
||||
parent_type integer not null,
|
||||
parent_type integer not null default 0,
|
||||
-- entity type to which this forum is attached:
|
||||
-- 0 == category (public)
|
||||
-- 1 == team
|
||||
|
|
|
@ -150,7 +150,7 @@ class BoincForumPrefs {
|
|||
} else {
|
||||
$prefs = self::lookup_userid($user->id);
|
||||
if (!$prefs) {
|
||||
self::insert("(userid, thread_sorting, pm_notification) values ($user->id, 8, 0)");
|
||||
self::insert("(userid, last_post, forum_sorting, thread_sorting, rated_posts, ignorelist, pm_notification) values ($user->id, 0, 0, 8, '', '', 0)");
|
||||
$prefs = self::lookup_userid($user->id);
|
||||
$prefs->userid = $user->id;
|
||||
$prefs->thread_sorting = 6;
|
||||
|
|
|
@ -559,7 +559,7 @@ function make_user(
|
|||
$country = BoincDb::escape_string($country);
|
||||
$postal_code = sanitize_tags(BoincDb::escape_string($postal_code));
|
||||
|
||||
$uid = BoincUser::insert("(create_time, email_addr, name, authenticator, country, postal_code, total_credit, expavg_credit, expavg_time, project_prefs, teamid, send_email, show_hosts, cross_project_id, passwd_hash) values($now, '$email_addr', '$name', '$authenticator', '$country', '$postal_code', 0, 0, unix_timestamp(), '$project_prefs', $teamid, 1, 1, '$cross_project_id', '$passwd_hash')");
|
||||
$uid = BoincUser::insert("(create_time, email_addr, name, authenticator, country, postal_code, total_credit, expavg_credit, expavg_time, project_prefs, teamid, venue, send_email, show_hosts, posts, seti_id, seti_nresults, seti_last_result_time, seti_total_cpu, has_profile, cross_project_id, passwd_hash, email_validated, donated) values($now, '$email_addr', '$name', '$authenticator', '$country', '$postal_code', 0, 0, unix_timestamp(), '$project_prefs', $teamid, '', 1, 1, 0, 0, 0, 0, 0, 0, '$cross_project_id', '$passwd_hash', 0, 0)");
|
||||
|
||||
if (!$uid) {
|
||||
return null;
|
||||
|
|
|
@ -975,6 +975,20 @@ function update_10_8_2014() {
|
|||
do_query("alter table user_submit_app add primary key(user_id, app_id)");
|
||||
}
|
||||
|
||||
function update_4_15_2015() {
|
||||
do_query("alter table forum
|
||||
alter timestamp set default 0,
|
||||
alter threads set default 0,
|
||||
alter posts set default 0,
|
||||
alter rate_min_expavg_credit set default 0,
|
||||
alter rate_min_total_credit set default 0,
|
||||
alter post_min_interval set default 0,
|
||||
alter post_min_expavg_credit set default 0,
|
||||
alter post_min_total_credit set default 0,
|
||||
alter parent_type set default 0
|
||||
");
|
||||
}
|
||||
|
||||
// Updates are done automatically if you use "upgrade".
|
||||
//
|
||||
// If you need to do updates manually,
|
||||
|
@ -1019,6 +1033,7 @@ $db_updates = array (
|
|||
array(27010, "update_6_5_2014"),
|
||||
array(27011, "update_8_15_2014"),
|
||||
array(27012, "update_10_8_2014"),
|
||||
array(27013, "update_4_15_2015"),
|
||||
);
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue