aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2010-10-30 11:52:41 +0200
committerAndreas Fischer <bantu@phpbb.com>2010-10-30 12:42:23 +0200
commitec3dac0595ea1a6c7071f16fca9e3373bd4027d4 (patch)
tree6211d9e19975c89592b27e3375fdd5710c7291a2
parent6ff403c9f8fd19e5ddf81fdf3e8bb27018b519b9 (diff)
downloadforums-ec3dac0595ea1a6c7071f16fca9e3373bd4027d4.tar
forums-ec3dac0595ea1a6c7071f16fca9e3373bd4027d4.tar.gz
forums-ec3dac0595ea1a6c7071f16fca9e3373bd4027d4.tar.bz2
forums-ec3dac0595ea1a6c7071f16fca9e3373bd4027d4.tar.xz
forums-ec3dac0595ea1a6c7071f16fca9e3373bd4027d4.zip
[ticket/9075] CPF Numbers fields: Prevent SQL error on registration page.
When an administrator set a numbers field to default to 'not specified', a SQL error was caused on the registration page because it was tried to insert an empty string into an integer column. Because the column already supports NULL values, empty strings are now converted to NULL for custom profile fields of the type 'Numbers' before insertion into the data table. PHPBB3-9075
-rw-r--r--phpBB/includes/functions_profile_fields.php5
1 files changed, 5 insertions, 0 deletions
diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php
index 3937cf9c21..78fe049f40 100644
--- a/phpBB/includes/functions_profile_fields.php
+++ b/phpBB/includes/functions_profile_fields.php
@@ -878,6 +878,11 @@ class custom_profile
$now = getdate();
$row['field_default_value'] = sprintf('%2d-%2d-%4d', $now['mday'], $now['mon'], $now['year']);
}
+ else if ($row['field_default_value'] === '' && $row['field_type'] == FIELD_INT)
+ {
+ // We cannot insert an empty string into an integer column.
+ $row['field_default_value'] = NULL;
+ }
$cp_data['pf_' . $row['field_ident']] = (in_array($row['field_type'], array(FIELD_TEXT, FIELD_STRING))) ? $row['lang_default_value'] : $row['field_default_value'];
}