View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0011818 | mantisbt | public | 2010-04-20 17:10 | 2011-05-03 06:21 | |
| Reporter | SL-Gundam | Assigned To | |||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | new | Resolution | open | ||
| Platform | PHP 5.3.2 | OS | Windows 7 x64 | OS Version | 6.1 (Build 7600) |
| Product Version | 1.2.0 | ||||
| Summary | 0011818: Notice level error when $_SERVER['REMOTE_ADDR'] is unavailable | ||||
| Description | I receive a notice level error in MantisBT 1.2.0 when $_SERVER['REMOTE_ADDR'] is unavailable. core/email_api.php This variable is not available in certain situations, for example when PHP is run directly instead of through a webserver. | ||||
| Tags | No tags attached. | ||||
| Attached Files | 0001-Fix-for-possibly-missing-_SERVER-variable-11818.patch (1,531 bytes)
From c39e33d59e1184a6eaf6941e78a7174dfd3b42eb Mon Sep 17 00:00:00 2001
From: SL-Gundam <slgundam@gmail.com>
Date: Mon, 15 Nov 2010 23:59:33 +0100
Subject: [PATCH] Fix for possibly missing $_SERVER variable (#11818)
Signed-off-by: SL-Gundam <slgundam@gmail.com>
---
core/email_api.php | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/core/email_api.php b/core/email_api.php
index dcd3136..807ecbd 100644
--- a/core/email_api.php
+++ b/core/email_api.php
@@ -512,7 +512,7 @@ function email_notify_new_account( $p_username, $p_email ) {
$t_recipient_email = user_get_email( $t_user['id'] );
$t_subject = '[' . config_get( 'window_title' ) . '] ' . lang_get( 'new_account_subject' );
- $t_message = lang_get( 'new_account_signup_msg' ) . "\n\n" . lang_get( 'new_account_username' ) . ' ' . $p_username . "\n" . lang_get( 'new_account_email' ) . ' ' . $p_email . "\n" . lang_get( 'new_account_IP' ) . ' ' . $_SERVER["REMOTE_ADDR"] . "\n" . $g_path . "\n\n" . lang_get( 'new_account_do_not_reply' );
+ $t_message = lang_get( 'new_account_signup_msg' ) . "\n\n" . lang_get( 'new_account_username' ) . ' ' . $p_username . "\n" . lang_get( 'new_account_email' ) . ' ' . $p_email . "\n" . lang_get( 'new_account_IP' ) . ' ' . ( ( isset( $_SERVER["REMOTE_ADDR"] ) ) ? $_SERVER["REMOTE_ADDR"] : 'CLI PHP' ) . "\n" . $g_path . "\n\n" . lang_get( 'new_account_do_not_reply' );
if( !is_blank( $t_recipient_email ) ) {
email_store( $t_recipient_email, $t_subject, $t_message );
--
1.7.3.1.msysgit.0
| ||||
|
AFAIK there isn't much we can do... MantisBT was designed to be executed by a web server and the problem I see is that email_api (and the functions it uses) will probably rely upon other API that haven't been designed to run from the command line. I can understand why you'd want to use functions from email_api.php via CLI PHP and agree with the direction you're heading with this bug report. We may get lucky in this case... so are you able to let me know if removing the reference to the $_SERVER variable solves this issue for you? |
|
|
Removing it would solve it. But i fixed it in a different way I encountered it during my programming for the EmailReporting plugin (0004286) That plugin creates new user accounts if necessary. Currently i implemented the work around by filling the value with 127.0.0.1 if the variable does not exist like this: But thats just a workaround for the plugin. Its possible not all webservers provide this $_SERVER variable For something that was not designed for use with CLI PHP, i have surprisingly almost no problems. This was actually the first problem (and only at the moment) :D |
|
|
Added a possible fix for this issue for the 1.2.x branch |
|