Skip to content

Commit ae1d830

Browse files
authored
Merge pull request phpbb#6729 from rxu/ticket/17391
[ticket/17391] Fix PHP warning on creating group with the name already in use
2 parents 688c7ca + 4217dc4 commit ae1d830

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

phpBB/includes/acp/acp_groups.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ function main($id, $mode)
396396
$allow_desc_urls = $request->variable('desc_parse_urls', false);
397397
$allow_desc_smilies = $request->variable('desc_parse_smilies', false);
398398

399-
$submit_ary = array(
399+
$submit_ary = [
400400
'colour' => $request->variable('group_colour', ''),
401401
'rank' => $request->variable('group_rank', 0),
402402
'receive_pm' => isset($_REQUEST['group_receive_pm']) ? 1 : 0,
@@ -406,7 +406,13 @@ function main($id, $mode)
406406
'max_recipients' => $request->variable('group_max_recipients', 0),
407407
'founder_manage' => 0,
408408
'skip_auth' => $request->variable('group_skip_auth', 0),
409-
);
409+
410+
// Initialize avatar data
411+
'avatar' => $avatar_data['avatar'] ?? '',
412+
'avatar_type' => $avatar_data['avatar_type'] ?? '',
413+
'avatar_height' => $avatar_data['avatar_height'] ?? 0,
414+
'avatar_width' => $avatar_data['avatar_width'] ?? 0,
415+
];
410416

411417
if ($user->data['user_type'] == USER_FOUNDER)
412418
{

tests/functional/acp_groups_test.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,20 @@ public function test_acp_groups_teampage($group_id, $tick_legend, $tick_teampage
123123
$this->assertEquals((bool) $tick_teampage, (bool) ($this->form_data['group_teampage'] ?? false));
124124
}
125125
}
126+
127+
public function test_acp_groups_create_existing_name()
128+
{
129+
$this->group_manage_login();
130+
131+
$crawler = self::request('GET', 'adm/index.php?i=groups&mode=manage&sid=' . $this->sid);
132+
$form = $crawler->selectButton($this->lang('SUBMIT'))->form([
133+
'group_name' => 'Guests', // 'Guests' is the group name already in use for predefined Guests group
134+
]);
135+
136+
$crawler = self::submit($form);
137+
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
138+
$crawler = self::submit($form); // Just submit the form with selected group name
139+
140+
$this->assertStringContainsString($this->lang('GROUP_NAME_TAKEN'), $crawler->text());
141+
}
126142
}

0 commit comments

Comments
 (0)