Skip to content

Commit 9050623

Browse files
committed
Fix possible PHP error notice
1 parent 98d6352 commit 9050623

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

event/listener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function add_googleanalytics_configs($event)
125125
*/
126126
public function validate_googleanalytics_id($event)
127127
{
128-
$input = $event['cfg_array']['googleanalytics_id'];
128+
$input = isset($event['cfg_array']['googleanalytics_id']) ? $event['cfg_array']['googleanalytics_id'] : '';
129129

130130
// Check if the validate test is for google_analytics
131131
if ($input !== '' && $event['config_definition']['validate'] === 'googleanalytics_id')

tests/event/listener_test.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
require_once __DIR__ . '/../../../../../includes/functions_acp.php';
1414

15-
class event_listener_test extends \phpbb_test_case
15+
class listener_test extends \phpbb_test_case
1616
{
1717
/** @var \phpbb\googleanalytics\event\listener */
1818
protected $listener;
@@ -199,6 +199,11 @@ public function validate_googleanalytics_id_data()
199199
array('googleanalytics_id' => 'foo-bar-foo'),
200200
array('ACP_GOOGLEANALYTICS_ID_INVALID'),
201201
),
202+
array(
203+
// no googleanalytics_id, no error
204+
array('foo' => 'bar'),
205+
array(),
206+
),
202207
);
203208
}
204209

@@ -211,7 +216,7 @@ public function test_validate_googleanalytics_id($cfg_array, $expected_error)
211216
{
212217
$this->set_listener();
213218

214-
$config_name = 'googleanalytics_id';
219+
$config_name = key($cfg_array);
215220
$config_definition = array('validate' => 'googleanalytics_id');
216221
$error = array();
217222

0 commit comments

Comments
 (0)