diff options
-rwxr-xr-x | phpBB/bin/phpbbcli.php | 2 | ||||
-rw-r--r-- | phpBB/phpbb/log/log.php | 4 | ||||
-rw-r--r-- | tests/log/add_test.php | 9 |
3 files changed, 13 insertions, 2 deletions
diff --git a/phpBB/bin/phpbbcli.php b/phpBB/bin/phpbbcli.php index e1f81662d2..72f1785931 100755 --- a/phpBB/bin/phpbbcli.php +++ b/phpBB/bin/phpbbcli.php @@ -70,6 +70,8 @@ require($phpbb_root_path . 'includes/compatibility_globals.' . $phpEx); /* @var $user \phpbb\user */ $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'); diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 436c21bdad..ee002c560a 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 ? (int) $user_id : ANONYMOUS, - 'log_ip' => empty($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 cfc592a464..ea1ae74d53 100644 --- a/tests/log/add_test.php +++ b/tests/log/add_test.php @@ -92,5 +92,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'); } } |