phpsms
phpsms copied to clipboard
[版本号:1.8]自定义代理器的同学注意下
如果你们做自定义代理器,要注意库里的代码有一处有问题,
Toplan\PhpSms\Sms.php的289行开始
代码是:
if (!empty($options)) {
self::$agents[$name] = new ParasiticAgent($config, $options);
} elseif (class_exists($className)) {
self::$agents[$name] = new $className($config);
} else {
throw new PhpSmsException("Not support agent `$name`.");
}
这样如果你在phpsms.php里的scheme里以数组的形式设置了你的自定义代理器并加了weight,
比如
'scheme' => [
App\agents\AAA\Agent::class => [
'20',
'agentClass' => App\Libs\AAA\Agent::class
],
App\agents\BBB\Agent::class => [
'10 backup',
'agentClass' => App\Libs\BBB\Agent::class
]
]
那么这两个Agent经过那段代码后,就跑ParasiticAgent去了。
所以,要不就不要有weight,这样的后果 我不知道会不会造成没有权重的特性了,
我也没多看其它代码,就把elseif改了一下
if (!empty($options)) {
self::$agents[$name] = new ParasiticAgent($config, $options);
}
if (class_exists($className)) {
self::$agents[$name] = new $className($config);
} else {
throw new PhpSmsException("Not support agent `$name`.");
}
希望遇到同样问题的同学能看到,着实弄了我半天。醉了!