Skip to:
Content

bbPress.org

Opened 10 years ago

Closed 10 years ago

#2750 closed defect (bug) (fixed)

Unit tests output notices from bbp_current_author_ip()

Reported by: johnjamesjacoby's profile johnjamesjacoby Owned by: johnjamesjacoby's profile johnjamesjacoby
Milestone: 2.6 Priority: normal
Severity: normal Version: 2.1
Component: General Keywords:
Cc:

Description

Starting to setup PHPUnit, I'm getting notices from bbp_current_author_ip() because of our direct and unchecked use of $_SERVER['REMOTE_ADDR']

PHP Notice:  Undefined index: REMOTE_ADDR in /includes/users/functions.php on line 146

Change History (2)

#1 @johnjamesjacoby
10 years ago

This can safely be fixed with an empty() check to start. In the event there's no REMOTE_ADDR I propose we force the IP address to '0.0.0.0' so at least there's an indication something strange occurred.

#2 @johnjamesjacoby
10 years ago

  • Owner set to johnjamesjacoby
  • Resolution set to fixed
  • Status changed from new to closed

In 5609:

In bbp_current_author_ip() check $_SERVER['REMOTE_ADDR'] before attempting to parse it.

If it is empty (more likely for unit tests, but could be other oddities) we set it to '0.0.0.0' to do two things:

  • Indicate to keymasters that something is amiss
  • Allow bbp_current_author_ip() to proceed normally for the end-user

Fixes #2750.

Note: See TracTickets for help on using tickets.