From 0cc41b94b1715ed6ae0175f77403410552f671af Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sun, 10 Jan 2016 17:43:10 +0100 Subject: [PATCH 1/2] [ticket/14403] Don't expect user_id and user_ip in phpbb\log PHPBB3-14403 --- phpBB/phpbb/log/log.php | 4 ++-- tests/log/add_test.php | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 3d995b4e4a..d46e3d1f3f 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -229,8 +229,8 @@ class log implements \phpbb\log\log_interface } $sql_ary = array( - 'user_id' => $user_id, - 'log_ip' => $log_ip, + 'user_id' => !empty($user_id) ? $user_id : ANONYMOUS, + 'log_ip' => !empty($log_ip) ? $log_ip : '', 'log_time' => $log_time, 'log_operation' => $log_operation, ); diff --git a/tests/log/add_test.php b/tests/log/add_test.php index bacc0c76f7..29d3adaeb6 100644 --- a/tests/log/add_test.php +++ b/tests/log/add_test.php @@ -88,5 +88,14 @@ class phpbb_log_add_test extends phpbb_database_test_case // Invalid mode specified $this->assertFalse($log->add('mode_does_not_exist', $user_id, $log_ip, $log_operation, $log_time)); + + // null user and null ip given + $this->assertEquals(3, $log->add($mode, null, null, $log_operation, $log_time), 'Adding log with null user_id and null user_ip failed'); + $sql = 'SELECT user_id, log_ip FROM ' . LOG_TABLE . ' WHERE log_id = 3'; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + $this->assertEquals(ANONYMOUS, $row['user_id'], 'Adding log with null user_id failed'); + $this->assertEquals('', $row['log_ip'], 'Adding log with null user_ip failed'); } } From d045822cd8cc2220a2ad3e159e3b688cb4049c12 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Wed, 13 Jan 2016 18:11:43 +0100 Subject: [PATCH 2/2] [ticket/14403] Set a default user id and ip in CLI PHPBB3-14403 --- phpBB/bin/phpbbcli.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpBB/bin/phpbbcli.php b/phpBB/bin/phpbbcli.php index ca425ad0c4..239dd3932b 100755 --- a/phpBB/bin/phpbbcli.php +++ b/phpBB/bin/phpbbcli.php @@ -59,6 +59,8 @@ $phpbb_container->get('request')->enable_super_globals(); require($phpbb_root_path . 'includes/compatibility_globals.' . $phpEx); $user = $phpbb_container->get('user'); +$user->data['user_id'] = ANONYMOUS; +$user->ip = '127.0.0.1'; $user->add_lang('acp/common'); $user->add_lang('cli');