Skip to content

Commit 42d8362

Browse files
committed
[ticket/16944] Add missing definitions and make logging optional
PHPBB3-16944
1 parent b4ff751 commit 42d8362

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

assets/iconify_bundler.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
namespace phpbb\assets;
1515

1616
use Iconify\JSONTools\Collection;
17+
use phpbb\log\log_interface;
1718

1819
class iconify_bundler
1920
{
20-
/** @var \phpbb\log\log_interface */
21+
/** @var log_interface */
2122
protected $log;
2223

2324
/** @var string[] Icons list */
@@ -26,9 +27,9 @@ class iconify_bundler
2627
/**
2728
* Constructor for iconify bundler
2829
*
29-
* @param \phpbb\log\log_interface $log Logger
30+
* @param log_interface|null $log Logger
3031
*/
31-
public function __construct(\phpbb\log\log_interface $log)
32+
public function __construct(?log_interface $log)
3233
{
3334
$this->log = $log;
3435
}
@@ -113,7 +114,10 @@ protected function organize_icons_list(): array
113114
if ($icon === null || $icon['provider'] !== '')
114115
{
115116
// Invalid name or icon name does not have provider
116-
$this->log->add('critical', ANONYMOUS, '', 'LOG_ICON_INVALID', false, [$icon_name]);
117+
if ($this->log)
118+
{
119+
$this->log->add('critical', ANONYMOUS, '', 'LOG_ICON_INVALID', false, [$icon_name]);
120+
}
117121
continue;
118122
}
119123

@@ -214,15 +218,22 @@ protected function load_icons_data(array $icons): string
214218
$collection = new Collection($prefix);
215219
if (!$collection->loadIconifyCollection($prefix))
216220
{
217-
$this->log->add('critical', ANONYMOUS, '', 'LOG_ICON_COLLECTION_INVALID', false, [$prefix]);
221+
if ($this->log)
222+
{
223+
$this->log->add('critical', ANONYMOUS, '', 'LOG_ICON_COLLECTION_INVALID', false, [$prefix]);
224+
}
225+
continue;
218226
}
219227

220228
// Make sure all icons exist
221229
foreach ($iconsList as $name)
222230
{
223231
if (!$collection->iconExists($name))
224232
{
225-
$this->log->add('critical', ANONYMOUS, '', 'LOG_ICON_INVALID', false, [$prefix . ':' . $name]);
233+
if ($this->log)
234+
{
235+
$this->log->add('critical', ANONYMOUS, '', 'LOG_ICON_INVALID', false, [$prefix . ':' . $name]);
236+
}
226237
}
227238
}
228239

0 commit comments

Comments
 (0)