Needs work
Project:
IP-based Determination of a Visitor's Country
Version:
2.0.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
28 Apr 2010 at 12:40 UTC
Updated:
29 Oct 2021 at 02:35 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
tr commentedI will be implementing this first in the 7.x-1.x branch, then possibly backporting it to 6.x-1.x.
Comment #2
tr commentedComment #3
tr commentedThis module has a debug configuration setting, but that only affects lookups done through the administrative UI and the country code attached to the User when a user logs in. This debug setting should also affect lookups done by other modules using the ip2country.manager service.
Comment #4
joshi.rohit100Added for D8
Comment #5
joshi.rohit100Comment #6
tr commentedI'm thinking there should be setDebug()/getDebug() methods as part of the ip2country.manager service so that other modules can manipulate the debug configuration variable. The logger call can be moved to setDebug() so that only changes in debug are logged (not on every call to getCountry() like in your patch), and the Ip2CountrySettingsForm should use the new set/get methods instead of directly accessing the config. Also it looks like you check the test_type but only implement the test_country case, not the test_ip_address case?
Or, perhaps introduce a hook_ip2country_alter() - this is something which I thought of doing a long time ago, and there are even skeleton tests for this hook, though they don't do anything yet. The idea would be to call the hook inside getCountry() - this would allow us to alter the returned country in any way. Then debug mode is simply a hook implementation in ip2country.module which returns the debug country or ip depending on the test type.
I'm about to push some changes to a lot of these files as part of #2921155: Remove usage of deprecated ip2country_get_country(), which will break your patch...
Comment #7
joshi.rohit100I am not sure about the setDebug()/getDebug() as semantically not making sense. For having alter hook as option, again the idea of debug mode from UI is that user enables the debug mode and it should work without writing any code. Although in getCountry() we can dispatch event for users to do something.
Comment #8
tr commentedMoving to current development branch.