Merge pull request #2584 from mrtorrent/fix_instanceid_format
Fix instanceid format to prevent session loop
This commit is contained in:
commit
66d7cc4c74
25
lib/util.php
25
lib/util.php
|
@ -411,18 +411,19 @@ class OC_Util {
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get an id unqiue for this instance
|
* get an id unique for this instance
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function getInstanceId() {
|
public static function getInstanceId() {
|
||||||
$id=OC_Config::getValue('instanceid', null);
|
$id = OC_Config::getValue('instanceid', null);
|
||||||
if(is_null($id)) {
|
if(is_null($id)) {
|
||||||
$id=uniqid();
|
// We need to guarantee at least one letter in instanceid so it can be used as the session_name
|
||||||
OC_Config::setValue('instanceid', $id);
|
$id = 'oc' . uniqid();
|
||||||
}
|
OC_Config::setValue('instanceid', $id);
|
||||||
return $id;
|
}
|
||||||
}
|
return $id;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Static lifespan (in seconds) when a request token expires.
|
* @brief Static lifespan (in seconds) when a request token expires.
|
||||||
|
|
|
@ -54,4 +54,9 @@ class Test_Util extends PHPUnit_Framework_TestCase {
|
||||||
$this->assertEquals('no-reply@example.com', $email);
|
$this->assertEquals('no-reply@example.com', $email);
|
||||||
OC_Config::deleteKey('mail_domain');
|
OC_Config::deleteKey('mail_domain');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testGetInstanceIdGeneratesValidId() {
|
||||||
|
OC_Config::deleteKey('instanceid');
|
||||||
|
$this->assertStringStartsWith('oc', OC_Util::getInstanceId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue