From 86c4d24a8ac14c4339806871ab326aedec4965e9 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 30 Mar 2014 15:44:58 +0200 Subject: [PATCH 1/2] [ticket/12331] Fix SQL error when inserting a new entry to profile field data There was a "Field 'pf_phpbb_interests' doesn't have a default value" error, because we didn't specify values for the disabled fields. We can not disable the sql_return_on_error() thou, because it otherwise we run into "Duplicate entry '2' for key 'PRIMARY'" errors when the user submits the form again but didn't change any values. PHPBB3-12331 --- phpBB/phpbb/profilefields/manager.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/phpbb/profilefields/manager.php b/phpBB/phpbb/profilefields/manager.php index a4626bc5de..f4baec7a6c 100644 --- a/phpBB/phpbb/profilefields/manager.php +++ b/phpBB/phpbb/profilefields/manager.php @@ -231,6 +231,7 @@ class manager if (!$this->db->sql_affectedrows()) { + $cp_data = $this->build_insert_sql_array($cp_data); $cp_data['user_id'] = (int) $user_id; $this->db->sql_return_on_error(true); From 45e6dd23e90fb3cc65f2b2454579f738fb81d293 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 1 Apr 2014 21:36:11 +0200 Subject: [PATCH 2/2] [ticket/12331] Add functional test for saving custom profile fields PHPBB3-12331 --- tests/functional/ucp_profile_test.php | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/functional/ucp_profile_test.php diff --git a/tests/functional/ucp_profile_test.php b/tests/functional/ucp_profile_test.php new file mode 100644 index 0000000000..e0e6255f79 --- /dev/null +++ b/tests/functional/ucp_profile_test.php @@ -0,0 +1,33 @@ +add_lang('ucp'); + $this->login(); + + $crawler = self::request('GET', 'ucp.php?i=ucp_profile&mode=profile_info'); + $this->assertContainsLang('UCP_PROFILE_PROFILE_INFO', $crawler->filter('#cp-main h2')->text()); + + $form = $crawler->selectButton('Submit')->form(array( + 'pf_phpbb_location' => 'Bertie“s Empire', + )); + $crawler = self::submit($form); + $this->assertContainsLang('PROFILE_UPDATED', $crawler->filter('#message')->text()); + + $crawler = self::request('GET', 'ucp.php?i=ucp_profile&mode=profile_info'); + $form = $crawler->selectButton('Submit')->form(); + $this->assertEquals('Bertie“s Empire', $form->get('pf_phpbb_location')->getValue()); + } +}