mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
Merge pull request #6813 from rxu/ticket/17508
[ticket/17508] Fix PHP warning on custom profile fields edit
This commit is contained in:
commit
61bede748a
2 changed files with 63 additions and 0 deletions
|
@ -475,6 +475,41 @@ class acp_profile
|
||||||
$cp->vars[$key] = $var;
|
$cp->vars[$key] = $var;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// step 3 - all arrays
|
||||||
|
if ($action == 'edit')
|
||||||
|
{
|
||||||
|
// Get language entries
|
||||||
|
$sql = 'SELECT *
|
||||||
|
FROM ' . PROFILE_FIELDS_LANG_TABLE . '
|
||||||
|
WHERE lang_id <> ' . $this->edit_lang_id . "
|
||||||
|
AND field_id = $field_id
|
||||||
|
ORDER BY option_id ASC";
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
$l_lang_options = [];
|
||||||
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
$l_lang_options[$row['lang_id']][$row['option_id']] = $row['lang_value'];
|
||||||
|
}
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
$sql = 'SELECT lang_id, lang_name, lang_explain, lang_default_value
|
||||||
|
FROM ' . PROFILE_LANG_TABLE . '
|
||||||
|
WHERE lang_id <> ' . $this->edit_lang_id . "
|
||||||
|
AND field_id = $field_id
|
||||||
|
ORDER BY lang_id ASC";
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
$l_lang_name = $l_lang_explain = $l_lang_default_value = [];
|
||||||
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
$l_lang_name[$row['lang_id']] = $row['lang_name'];
|
||||||
|
$l_lang_explain[$row['lang_id']] = $row['lang_explain'];
|
||||||
|
$l_lang_default_value[$row['lang_id']] = $row['lang_default_value'];
|
||||||
|
}
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($exclude[3] as $key)
|
foreach ($exclude[3] as $key)
|
||||||
{
|
{
|
||||||
$cp->vars[$key] = $request->variable($key, array(0 => ''), true);
|
$cp->vars[$key] = $request->variable($key, array(0 => ''), true);
|
||||||
|
|
|
@ -69,4 +69,32 @@ class phpbb_functional_acp_profile_field_test extends phpbb_functional_test_case
|
||||||
|
|
||||||
$this->assertContainsLang('ADDED_PROFILE_FIELD', $crawler->text());
|
$this->assertContainsLang('ADDED_PROFILE_FIELD', $crawler->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_edit_profile_fields()
|
||||||
|
{
|
||||||
|
// Custom profile fields page
|
||||||
|
$crawler = self::request('GET', 'adm/index.php?i=acp_profile&mode=profile&sid=' . $this->sid);
|
||||||
|
|
||||||
|
// Get all profile fields edit URLs
|
||||||
|
$edits = $crawler->filter('td.actions a')
|
||||||
|
->reduce(
|
||||||
|
function ($node, $i) {
|
||||||
|
$url = $node->attr('href');
|
||||||
|
return ((bool) strpos($url, 'action=edit'));
|
||||||
|
})
|
||||||
|
->each(
|
||||||
|
function ($node, $i) {
|
||||||
|
$url = $node->attr('href');
|
||||||
|
return ($url);
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach ($edits as $edit_url)
|
||||||
|
{
|
||||||
|
$crawler = self::request('GET', 'adm/' . $edit_url . '&sid=' . $this->sid);
|
||||||
|
$form = $crawler->selectButton('Save')->form();
|
||||||
|
$crawler= self::submit($form);
|
||||||
|
|
||||||
|
$this->assertContainsLang('CHANGED_PROFILE_FIELD', $crawler->text());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue