[livejournal] r8983: -- latest LJ::sms_gateway change was bro...

Sep 20, 2006 07:20


Committer: whitaker-- latest LJ::sms_gateway change was broken as it
introduced the concept of multiple gateway
types, but still cached globally per-process

U branches/sms/cgi-bin/ljlib.pl

Modified: branches/sms/cgi-bin/ljlib.pl
===================================================================
--- branches/sms/cgi-bin/ljlib.pl 2006-09-20 07:14:43 UTC (rev 8982)
+++ branches/sms/cgi-bin/ljlib.pl 2006-09-20 07:20:30 UTC (rev 8983)
@@ -241,19 +241,22 @@
}

sub sms_gateway {
- my $gateway_type = shift;
- return $LJ::SMS_GATEWAY ||= do {
+ my $conf_key = shift;
+
+ # effective config key is 'default' if one wasn't specified or nonexistent
+ # config was specified, meaning fall back to default
+ unless ($conf_key && $LJ::SMS_GATEWAY_CONFIG{$conf_key}) {
+ $conf_key = 'default';
+ }
+
+ return $LJ::SMS_GATEWAY{$conf_key} ||= do {
my $class = "DSMS::Gateway" .
($LJ::SMS_GATEWAY_TYPE ? "::$LJ::SMS_GATEWAY_TYPE" : "");

eval "use $class";
die "unable to use $class: $@" if $@;

- my $config;
- $config = $LJ::SMS_GATEWAY_CONFIG{$gateway_type} if $gateway_type;
- $config ||= $LJ::SMS_GATEWAY_CONFIG{default};
-
- return $class->new(config => $config);
+ $class->new(config => $LJ::SMS_GATEWAY_CONFIG{$conf_key});
};
}

Previous post Next post
Up