BUGFIX Disable Geoip if in CLI mode - this fixes the tests from breaking. The geoip command won't be available in CLI context

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@75161 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2009-04-27 01:56:55 +00:00 committed by Sam Minnee
parent 8e72a975b0
commit d8b22a0582

View File

@ -278,6 +278,9 @@ class Geoip extends Object {
* @param boolean $codeOnly Returns just the country code
*/
static function ip2country($address, $codeOnly = false) {
// Return if in CLI, or you'll get this error: "sh: geoiplookup: command not found"
if(Director::is_cli()) return false;
$cmd = 'geoiplookup ' . escapeshellarg($address);
exec($cmd, $result, $code);
// Note: At time of writing, $result is always zero for this program