Calling an empty function via CLI and getting this notice level error back:
starovich> php index.php utils empty_function
<div>
<h4>A PHP Error was encountered</h4>
<p>Severity: Notice</p>
<p>Message: Undefined index: REMOTE_ADDR</p>
<p>Filename: core/Input.php</p>
<p>Line Number: 351</p>
</div><div>
<h4>A PHP Error was encountered</h4>
<p>Severity: Warning</p>
<p>Message: Cannot modify header information - headers already sent by (output started at /media/sf_www-host/project/system/core/Exceptions.php:185)</p>
<p>Filename: libraries/Session.php</p>
<p>Line Number: 675</p>
Problem stems from assuming that $_SERVER[‘REMOTE_ADDR’] exists, which is not the case in CLI mode.
It can be easily fixed by adding a check in core/Input.php Line 351 (CI 2.1.2):
From:
$this->ip_address = $_SERVER['REMOTE_ADDR'];
To:
if(isset($_SERVER['REMOTE_ADDR']))
$this->ip_address = $_SERVER['REMOTE_ADDR'];
else
$this->ip_address = '0.0.0.0';
This or a similar fix should probably be included in the next release to avoid these messages. Thanks!
