From 57bbb4548b2761c01fc14345982e00be1ea27af1 Mon Sep 17 00:00:00 2001 From: Stanislav Atanasov Date: Thu, 10 Jul 2014 06:12:13 +0300 Subject: [PATCH 1/3] [ticket/12793] String '0' does not display for string profile fields See https://github.com/phpbb/phpbb/pull/2647#discussion_r14503051 PHPBB3-12793 --- phpBB/phpbb/profilefields/type/type_string_common.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/phpbb/profilefields/type/type_string_common.php b/phpBB/phpbb/profilefields/type/type_string_common.php index c2b951b6c9..0842675a11 100644 --- a/phpBB/phpbb/profilefields/type/type_string_common.php +++ b/phpBB/phpbb/profilefields/type/type_string_common.php @@ -98,7 +98,7 @@ abstract class type_string_common extends type_base */ public function get_profile_value($field_value, $field_data) { - if (!$field_value && !$field_data['field_show_novalue']) + if (($field_value === null || $field_value === '') && !$field_data['field_show_novalue']) { return null; } @@ -114,7 +114,7 @@ abstract class type_string_common extends type_base */ public function get_profile_value_raw($field_value, $field_data) { - if (!$field_value && !$field_data['field_show_novalue']) + if (($field_value === null || $field_value === '') && !$field_data['field_show_novalue']) { return null; } @@ -127,7 +127,7 @@ abstract class type_string_common extends type_base */ public function get_profile_contact_value($field_value, $field_data) { - if (!$field_value && !$field_data['field_show_novalue']) + if (($field_value === null || $field_value === '') && !$field_data['field_show_novalue']) { return null; } From 223c634bee355f8df521163e33585b0abf1e1f69 Mon Sep 17 00:00:00 2001 From: Stanislav Atanasov Date: Thu, 10 Jul 2014 11:32:30 +0300 Subject: [PATCH 2/3] [ticket/12793] Changing get_profile_contact_value to get_profile_value_raw Changing the return to get_profile_value_raw PHPBB3-12793 --- phpBB/phpbb/profilefields/type/type_string_common.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/phpBB/phpbb/profilefields/type/type_string_common.php b/phpBB/phpbb/profilefields/type/type_string_common.php index 0842675a11..0eaf7e527d 100644 --- a/phpBB/phpbb/profilefields/type/type_string_common.php +++ b/phpBB/phpbb/profilefields/type/type_string_common.php @@ -127,12 +127,7 @@ abstract class type_string_common extends type_base */ public function get_profile_contact_value($field_value, $field_data) { - if (($field_value === null || $field_value === '') && !$field_data['field_show_novalue']) - { - return null; - } - - return $field_value; + return $this->get_profile_value_raw($field_value, $field_data); } /** From 902937ce70ae1c992a120679fc7b0a0134c5451d Mon Sep 17 00:00:00 2001 From: Stanislav Atanasov Date: Thu, 10 Jul 2014 11:53:10 +0300 Subject: [PATCH 3/3] [ticket/12793] Tests (added and changed) changed behavieur of 0 as in and added 0 as string test PHPBB3-12793 --- tests/profilefields/type_string_test.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/profilefields/type_string_test.php b/tests/profilefields/type_string_test.php index f6c14ee38b..2277526758 100644 --- a/tests/profilefields/type_string_test.php +++ b/tests/profilefields/type_string_test.php @@ -249,8 +249,14 @@ class phpbb_profilefield_type_string_test extends phpbb_test_case array( 0, array('field_show_novalue' => false), - null, - 'Field should return null for empty integer without show_novalue', + 0, + 'Field should return value of integer 0 without show_novalue', + ), + array( + '0', + array('field_show_novalue' => false), + '0', + 'Field should return string 0', ), array( 0,