Hi everyone,
if you call the method below like that : OAuthStore::instance("2Leg", $options1);
and then call (in the same script) : OAuthStore::instance("2Leg", $options2);
with $options1 and $options2 that are different. The instance of the singleton will not be updated and the second call will use options of the first call and the signature of your OAuth second call will by consequence fail.
To correct that use, I change the code of the OAuthStore.php file like that (take a look at the $forceNewInstance parameter) : class OAuthStore { static private $instance = false;
/**
* Request an instance of the OAuthStore
*/
public static function instance ( $store = 'MySQL', $options = array(), $forceNewInstance = false )
{
if (!OAuthStore::$instance || $forceNewInstance)
{
// Select the store you want to use
if (strpos($store, '/') === false)
{
$class = 'OAuthStore'.$store;
$file = dirname(__FILE__) . '/store/'.$class.'.php';
}
else
{
$file = $store;
$store = basename($file, '.php');
$class = $store;
}
if (is_file($file))
{
require_once $file;
if (class_exists($class))
{
OAuthStore::$instance = new $class($options);
}
else
{
throw new OAuthException2('Could not find class '.$class.' in file '.$file);
}
}
else
{
throw new OAuthException2('No OAuthStore for '.$store.' (file '.$file.')');
}
}
return OAuthStore::$instance;
}
}
Comment #1
Posted on Jan 12, 2011 by Massive LionI'm not sure why you'd need to change stores, but you probably have a reason to do so. So your patch is accepted and in r182. Thanks!
Status: Fixed
Labels:
Type-Defect
Priority-Medium