Skip to content

Commit 61bede7

Browse files
authored
Merge pull request phpbb#6813 from rxu/ticket/17508
[ticket/17508] Fix PHP warning on custom profile fields edit
2 parents f94423d + 0562984 commit 61bede7

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

phpBB/includes/acp/acp_profile.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,41 @@ function main($id, $mode)
475475
$cp->vars[$key] = $var;
476476
}
477477

478+
// step 3 - all arrays
479+
if ($action == 'edit')
480+
{
481+
// Get language entries
482+
$sql = 'SELECT *
483+
FROM ' . PROFILE_FIELDS_LANG_TABLE . '
484+
WHERE lang_id <> ' . $this->edit_lang_id . "
485+
AND field_id = $field_id
486+
ORDER BY option_id ASC";
487+
$result = $db->sql_query($sql);
488+
489+
$l_lang_options = [];
490+
while ($row = $db->sql_fetchrow($result))
491+
{
492+
$l_lang_options[$row['lang_id']][$row['option_id']] = $row['lang_value'];
493+
}
494+
$db->sql_freeresult($result);
495+
496+
$sql = 'SELECT lang_id, lang_name, lang_explain, lang_default_value
497+
FROM ' . PROFILE_LANG_TABLE . '
498+
WHERE lang_id <> ' . $this->edit_lang_id . "
499+
AND field_id = $field_id
500+
ORDER BY lang_id ASC";
501+
$result = $db->sql_query($sql);
502+
503+
$l_lang_name = $l_lang_explain = $l_lang_default_value = [];
504+
while ($row = $db->sql_fetchrow($result))
505+
{
506+
$l_lang_name[$row['lang_id']] = $row['lang_name'];
507+
$l_lang_explain[$row['lang_id']] = $row['lang_explain'];
508+
$l_lang_default_value[$row['lang_id']] = $row['lang_default_value'];
509+
}
510+
$db->sql_freeresult($result);
511+
}
512+
478513
foreach ($exclude[3] as $key)
479514
{
480515
$cp->vars[$key] = $request->variable($key, array(0 => ''), true);

tests/functional/acp_profile_field_test.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,32 @@ public function test_add_profile_field($type, $page1_settings)
6969

7070
$this->assertContainsLang('ADDED_PROFILE_FIELD', $crawler->text());
7171
}
72+
73+
public function test_edit_profile_fields()
74+
{
75+
// Custom profile fields page
76+
$crawler = self::request('GET', 'adm/index.php?i=acp_profile&mode=profile&sid=' . $this->sid);
77+
78+
// Get all profile fields edit URLs
79+
$edits = $crawler->filter('td.actions a')
80+
->reduce(
81+
function ($node, $i) {
82+
$url = $node->attr('href');
83+
return ((bool) strpos($url, 'action=edit'));
84+
})
85+
->each(
86+
function ($node, $i) {
87+
$url = $node->attr('href');
88+
return ($url);
89+
});
90+
91+
foreach ($edits as $edit_url)
92+
{
93+
$crawler = self::request('GET', 'adm/' . $edit_url . '&sid=' . $this->sid);
94+
$form = $crawler->selectButton('Save')->form();
95+
$crawler= self::submit($form);
96+
97+
$this->assertContainsLang('CHANGED_PROFILE_FIELD', $crawler->text());
98+
}
99+
}
72100
}

0 commit comments

Comments
 (0)