From 4311399909a89c72c9eb1cc3d759d29b7d2c9f46 Mon Sep 17 00:00:00 2001 From: Victor Boctor Date: Sat, 18 Dec 2010 14:41:11 -0800 Subject: [PATCH] Fix #12619: Custom fields are reported as required after upgrade from 1.1.0 to 1.2.3 --- bug_report.php | 2 -- core/custom_field_api.php | 18 ++++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/bug_report.php b/bug_report.php index 32393ce..47743bc 100644 --- a/bug_report.php +++ b/bug_report.php @@ -107,8 +107,6 @@ if ( !gpc_isset_custom_field( $t_id, $t_def['type'] ) && ( $t_def['require_report'] || $t_def['type'] == CUSTOM_FIELD_TYPE_ENUM || - $t_def['type'] == CUSTOM_FIELD_TYPE_LIST || - $t_def['type'] == CUSTOM_FIELD_TYPE_MULTILIST || $t_def['type'] == CUSTOM_FIELD_TYPE_RADIO ) ) { error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) ); trigger_error( ERROR_EMPTY_FIELD, ERROR ); diff --git a/core/custom_field_api.php b/core/custom_field_api.php index 3b0baa1..778fbc0 100644 --- a/core/custom_field_api.php +++ b/core/custom_field_api.php @@ -1175,14 +1175,20 @@ function custom_field_validate( $p_field_id, $p_value ) { } # If checkbox field value is not null then we need to validate it... (note: no "break" statement here!) case CUSTOM_FIELD_TYPE_MULTILIST: - $t_values = explode( '|', $p_value ); - $t_possible_values = custom_field_prepare_possible_values( $row['possible_values'] ); - $t_possible_values = explode( '|', $t_possible_values ); - $t_invalid_values = array_diff( $t_values, $t_possible_values ); - $t_valid &= ( count( $t_invalid_values ) == 0 ); + if ( $p_value !== '' ) { + $t_values = explode( '|', $p_value ); + $t_possible_values = custom_field_prepare_possible_values( $row['possible_values'] ); + $t_possible_values = explode( '|', $t_possible_values ); + $t_invalid_values = array_diff( $t_values, $t_possible_values ); + $t_valid &= ( count( $t_invalid_values ) == 0 ); + } break; - case CUSTOM_FIELD_TYPE_ENUM: case CUSTOM_FIELD_TYPE_LIST: + if ( $p_value === '' ) { + break; + } + # If list field value is not empty then we need to validate it... (note: no "break" statement here!) + case CUSTOM_FIELD_TYPE_ENUM: case CUSTOM_FIELD_TYPE_RADIO: $t_possible_values = custom_field_prepare_possible_values( $row['possible_values'] ); $t_values_arr = explode( '|', $t_possible_values ); -- 1.7.3.3