Skip to content

Commit 3821479

Browse files
author
Francois Suter
committed
[BUGFIX] Fix error due to null IP address
In the command-line context, the IP address from the referrer will be null. Replace by empty string to avoid DB-writing error.
1 parent 95af0e8 commit 3821479

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
2016-11-15 Francois Suter <[email protected]>
22

33
* Improved escaping of HTML content in log entries, resolves #2
4+
* Fixed error due to possibly null IP address (CLI context)
45

56
2016-11-13 Francois Suter <[email protected]>
67

Classes/Utility/Logger.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ public function log($logData)
9999
return;
100100
}
101101
// Add IP address for validation
102-
$logData['ip'] = GeneralUtility::getIndpEnv('REMOTE_ADDR');
102+
$ipAddress = GeneralUtility::getIndpEnv('REMOTE_ADDR');
103+
if ($ipAddress === null) {
104+
$ipAddress = '';
105+
}
106+
$logData['ip'] = $ipAddress;
103107
// If the log entry doesn't pass the basic filters, exit early doing nothing
104108
if (!$this->isEntryAccepted($logData)) {
105109
return;

0 commit comments

Comments
 (0)