Installed version 7.x-2.1 and set to allow one IP as well as certain roles to access. This error is coming up on the log in page for users that aren't white listed and sometimes for whitelisted users when logged in. The section to whitelist or blacklist by country is disabled. In order to enable, I would need to "Enable the Countries and IP-based Determination of a Visitor's Country modules to use this feature." I'm not sure if this is a bug.

Notice: Undefined variable: countries in restrict_ip_boot() (line 246 of <drupal_root>/sites/all/modules/contrib/restrict_ip/restrict_ip.module).

CommentFileSizeAuthor
#8 2877457-undefined-variable.patch442 bytesrschwab

Comments

christiahall created an issue. See original summary.

chri5tia’s picture

Issue summary: View changes
chri5tia’s picture

Issue summary: View changes
chri5tia’s picture

Issue summary: View changes
bkeller’s picture

I'm using this module to restrict access on a development site, and I've got so many of those errors that the dev site actually comes up in a Google search for this error... well that was embarrassing.
I can only assume that the Countries and IP Country modules populate those variables (I don't have either installed), because I didn't see anywhere that they were defined before line 246.
Anyway, to stop those error messages, I just wrapped those two variables in an isset check, and that seems to have stopped the messages.
Line 246:
if($access_denied && isset($countries) && isset($ip2country))
But again, for all I know adding that may negate the usage of those two modules.

antonyanimator’s picture

I am seeing this issue too, thanks @bkeller

chri5tia’s picture

I am using this to temporarily restrict access to the test site and production before it's launched. BKeller's fix #5, changing line 246 in the restrict_ip.module as noted worked for me, thanks!

rschwab’s picture

StatusFileSize
new442 bytes

Here is a patch for #5 - thank you bkeller!

antonyanimator’s picture

Status: Active » Reviewed & tested by the community

@rschwab thanks for the patch

nickonom’s picture

I do confirm patch takes care of the issue.

spanners’s picture

I just tried out this patch, but I now get the error...

Notice: Undefined property: stdClass::$data in restrict_ip_boot() (line 250 of /home/dimosdental/public_html/sites/all/modules/restrict_ip/restrict_ip.module).

On top of that, country blocking isn't working - regardless of whether I select Disabled, Whitelist or Blacklist, everyone is blocked except for the IPs specified in the first field.

I came from the other issue in the issue queue https://www.drupal.org/project/restrict_ip/issues/2956653 because I'm having the same problem.

Using 7.x-2.1 version of the module on at Drupal 7.59 site.

  • Jaypan committed 8018b62 on 7.x-2.x
    Issue #2877457 by rschwab, christiahall, nickonom, bkeller: Undefined...
jaypan’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the work and testing guys. The patch actually wasn't usable as-is, as it masked the problem instead of solving it. But the patch showed me exactly where the problem lay, and enabled me to re-write the code to fix it.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.