Skip to content
This repository has been archived by the owner on Jul 24, 2018. It is now read-only.

Commit

Permalink
Merge pull request #539 from owncloud/stable8.1-insertid
Browse files Browse the repository at this point in the history
Zero as a last inserted memberId
  • Loading branch information
VicDeo committed Sep 1, 2015
2 parents f31447e + 6b62199 commit 0f121e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function insert(){
* @return mixed
*/
public function getLastInsertId(){
return \OCP\DB::insertid($this->tableName);
return \OC::$server->getDatabaseConnection()->lastInsertId($this->tableName);
}

/**
Expand Down
9 changes: 6 additions & 3 deletions lib/db/session.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

namespace OCA\Documents\Db;

use OCP\Security\ISecureRandom;

use OCA\Documents\Filter;

/**
Expand Down Expand Up @@ -88,6 +90,7 @@ public static function start($uid, $file){
if (!$member->insert()){
throw new \Exception('Failed to add member into database');
}
$sessionData['member_id'] = (string) $member->getLastInsertId();

// Do we have OC_Avatar in out disposal?
if (\OC_Config::getValue('enable_avatars', true) !== true){
Expand All @@ -98,8 +101,6 @@ public static function start($uid, $file){

$displayName = $file->isPublicShare() ? $uid . ' ' . \OCA\Documents\Db\Member::getGuestPostfix() : \OCP\User::getDisplayName($uid);
$userId = $file->isPublicShare() ? $displayName : \OCP\User::getUser();

$sessionData['member_id'] = (string) $member->getLastInsertId();
$op = new \OCA\Documents\Db\Op();
$op->addMember(
$sessionData['es_id'],
Expand Down Expand Up @@ -204,7 +205,9 @@ public function getInfo($esId){
protected function getUniqueSessionId(){
$testSession = new Session();
do{
$id = \OC_Util::generateRandomBytes(30);
$id = \OC::$server->getSecureRandom()
->getMediumStrengthGenerator()
->generate(30, ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS);
} while ($testSession->load($id)->hasData());

return $id;
Expand Down

0 comments on commit 0f121e1

Please sign in to comment.