Skip to content

Commit f08480f

Browse files
authored
Merge pull request phpbb#6922 from marc1706/ticket/17602
[ticket/17602] Clean up avatar code and fix some misc test issues
2 parents f6dd0cc + 5ce6657 commit f08480f

File tree

7 files changed

+24
-28
lines changed

7 files changed

+24
-28
lines changed

phpBB/includes/acp/acp_users.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,11 +1897,6 @@ function main($id, $mode)
18971897

18981898
if ($request->is_ajax())
18991899
{
1900-
/** @var \phpbb\avatar\helper $avatar_helper */
1901-
$avatar_helper = $phpbb_container->get('avatar.helper');
1902-
1903-
$avatar = $avatar_helper->get_user_avatar($user->data, 'USER_AVATAR', true);
1904-
19051900
$json_response = new \phpbb\json_response;
19061901
$json_response->send([
19071902
'success' => true,

phpBB/includes/ucp/ucp_profile.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -665,11 +665,6 @@ function main($id, $mode)
665665

666666
if ($request->is_ajax())
667667
{
668-
/** @var \phpbb\avatar\helper $avatar_helper */
669-
$avatar_helper = $phpbb_container->get('avatar.helper');
670-
671-
$avatar = $avatar_helper->get_user_avatar($user->data, 'USER_AVATAR', true);
672-
673668
$json_response = new \phpbb\json_response;
674669
$json_response->send(array(
675670
'success' => true,

phpBB/phpbb/template/twig/extension/avatar.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,19 @@ public function get_avatar(environment $environment, array $row): string
7373
{
7474
try
7575
{
76+
// Quickly return if required data is missing
77+
if (!isset($row['src'], $row['width'], $row['height'], $row['title']))
78+
{
79+
return '';
80+
}
81+
7682
return $environment->render('macros/avatar.twig', [
77-
'SRC' => $row['lazy'] ? $this->avatar_helper->get_no_avatar_source() : $row['src'],
78-
'DATA_SRC' => $row['lazy'] ? $row['src'] : '',
83+
'SRC' => !empty($row['lazy']) ? $this->avatar_helper->get_no_avatar_source() : $row['src'],
84+
'DATA_SRC' => !empty($row['lazy']) ? $row['src'] : '',
7985
'WIDTH' => $row['width'],
8086
'HEIGHT' => $row['height'],
8187
'TITLE' => $row['title'],
82-
'LAZY' => $row['lazy'],
88+
'LAZY' => $row['lazy'] ?? false,
8389
]);
8490
}
8591
catch (Error $e)

tests/functional/manifest_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class phpbb_functional_manifest_test extends phpbb_functional_test_case
1818
{
1919
public function test_manifest()
2020
{
21-
$url_path = preg_replace('#^(/.+)/$#', '$1', parse_url(self::$root_url, PHP_URL_PATH));
21+
$url_path = preg_replace('#^(/.+)/$#', '$1/', parse_url(self::$root_url, PHP_URL_PATH));
2222

2323
$expected = [
2424
'name' => 'yourdomain.com',

tests/functional/viewonline_test.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function test_viewonline()
5757
$this->login();
5858
// PHP goes faster than DBMS, make sure session data got written to the database
5959
sleep(1);
60-
$crawler = self::request('GET', 'members/online');
60+
$crawler = self::request('GET', 'app.php/members/online');
6161
// Make sure posting reply page is in the list
6262
$this->assertStringContainsString('viewonline-test-user1', $crawler->text());
6363
$this->assertStringContainsString($this->lang('REPLYING_MESSAGE', $this->get_forum_name_by_topic_id(1)), $crawler->text());
@@ -72,7 +72,7 @@ public function test_viewonline()
7272
$this->login();
7373
// PHP goes faster than DBMS, make sure session data got written to the database
7474
sleep(1);
75-
$crawler = self::request('GET', 'members/online');
75+
$crawler = self::request('GET', 'app.php/members/online');
7676
// Make sure posting message page is in the list
7777
$this->assertStringContainsString('viewonline-test-user1', $crawler->text());
7878
$this->assertStringContainsString($this->lang('POSTING_MESSAGE', $this->get_forum_name_by_forum_id(2)), $crawler->text());
@@ -88,7 +88,7 @@ public function test_viewonline()
8888
$this->login();
8989
// PHP goes faster than DBMS, make sure session data got written to the database
9090
sleep(1);
91-
$crawler = self::request('GET', 'members/online');
91+
$crawler = self::request('GET', 'app.php/members/online');
9292
// Make sure posting message page is in the list
9393
$this->assertStringContainsString('viewonline-test-user1', $crawler->text());
9494
$this->assertStringContainsString($this->lang('POSTING_MESSAGE', $this->get_forum_name_by_forum_id(2)), $crawler->text());
@@ -102,7 +102,7 @@ public function test_viewonline()
102102
$this->login();
103103
// PHP goes faster than DBMS, make sure session data got written to the database
104104
sleep(1);
105-
$crawler = self::request('GET', 'members/online');
105+
$crawler = self::request('GET', 'app.php/members/online');
106106
// Make sure reading topic page is in the list
107107
$this->assertStringContainsString('viewonline-test-user1', $crawler->text());
108108
$this->assertStringContainsString($this->lang('READING_TOPIC', $this->get_forum_name_by_topic_id(1)), $crawler->text());
@@ -116,7 +116,7 @@ public function test_viewonline()
116116
$this->login();
117117
// PHP goes faster than DBMS, make sure session data got written to the database
118118
sleep(1);
119-
$crawler = self::request('GET', 'members/online');
119+
$crawler = self::request('GET', 'app.php/members/online');
120120
// Make sure reading forum page is in the list
121121
$this->assertStringContainsString('viewonline-test-user1', $crawler->text());
122122
$this->assertStringContainsString($this->lang('READING_FORUM', $this->get_forum_name_by_forum_id(2)), $crawler->text());

tests/session/check_ban_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ protected function setUp(): void
7575
// the mock cache object does not hit the database as is needed
7676
// for this test.
7777
$cache = new \phpbb\cache\service(
78-
new \phpbb\cache\driver\file(),
78+
new \phpbb\cache\driver\dummy(),
7979
$config,
8080
$this->db,
8181
$phpbb_dispatcher,

tests/wrapper/gmgetdate_test.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313

1414
class phpbb_wrapper_gmgetdate_test extends phpbb_test_case
1515
{
16-
public static function phpbb_gmgetdate_data()
16+
public static function phpbb_gmgetdate_data(): array
1717
{
18-
return array(
19-
array(''),
20-
array('UTC'),
21-
array('Europe/Berlin'),
22-
array('America/Los_Angeles'),
23-
array('Antarctica/South_Pole'),
24-
);
18+
return [
19+
[''],
20+
['UTC'],
21+
['Europe/Berlin'],
22+
['America/Los_Angeles'],
23+
['Pacific/Auckland'],
24+
];
2525
}
2626

2727
/**

0 commit comments

Comments
 (0)