From 4f6f9c424d124ec3839809828bbe45ae7a17436a Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sun, 19 Jul 2009 00:20:03 +0000 Subject: [PATCH] Permit null values for non-required integer custom profile fields and ensure zero complies with the range limits. #40925 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9788 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/docs/CHANGELOG.html | 1 + phpBB/includes/functions_profile_fields.php | 24 ++++++++------------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html index 8f667faef2..40e938546c 100644 --- a/phpBB/docs/CHANGELOG.html +++ b/phpBB/docs/CHANGELOG.html @@ -164,6 +164,7 @@
  • [Fix] Remove redundant SQL query from ucp.php. (Bug #40305)
  • [Fix] Reorder frame order of animated subsilver2 topic icons to be useful when animation is disabled. (Bug #29385 - Patch by prototech)
  • [Fix] Ensure user errors are displayed regardless of PHP settings. (Bug #47505)
  • +
  • [Fix] Permit null values for non-required integer custom profile fields and ensure zero complies with the range limits. (Bug #40925)
  • [Change] Change the data format of the default file ACM to be more secure from tampering and have better performance.
  • [Change] Add index on log_time to the log table to prevent slowdown on boards with many log entries. (Bug #44665 - Patch by bantu)
  • [Change] Template engine now permits to a limited extent variable includes.
  • diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php index bb1ec476c4..9e356414a9 100644 --- a/phpBB/includes/functions_profile_fields.php +++ b/phpBB/includes/functions_profile_fields.php @@ -90,18 +90,6 @@ class custom_profile */ function validate_profile_field($field_type, &$field_value, $field_data) { - switch ($field_type) - { - case FIELD_INT: - case FIELD_DROPDOWN: - $field_value = (int) $field_value; - break; - - case FIELD_BOOL: - $field_value = (bool) $field_value; - break; - } - switch ($field_type) { case FIELD_DATE: @@ -133,6 +121,8 @@ class custom_profile break; case FIELD_BOOL: + $field_value = (bool) $field_value; + if (!$field_value && $field_data['field_required']) { return 'FIELD_REQUIRED'; @@ -140,10 +130,12 @@ class custom_profile break; case FIELD_INT: - if (empty($field_value) && !$field_data['field_required']) + if (trim($field_value) === '' && !$field_data['field_required']) { return false; } + + $field_value = (int) $field_value; if ($field_value < $field_data['field_minlen']) { @@ -156,6 +148,8 @@ class custom_profile break; case FIELD_DROPDOWN: + $field_value = (int) $field_value; + if ($field_value == $field_data['field_novalue'] && $field_data['field_required']) { return 'FIELD_REQUIRED'; @@ -514,7 +508,7 @@ class custom_profile switch ($this->profile_types[$field_type]) { case 'int': - if ($value == '') + if ($value === '') { return NULL; } @@ -644,7 +638,7 @@ class custom_profile } } - return (is_null($value)) ? '' : (int) $value; + return (is_null($value) || $value === '') ? '' : (int) $value; } else {