Skip to content

Commit

Permalink
Fixed issue: If the participant table is too big the token generation…
Browse files Browse the repository at this point in the history
… may fail due to memory shortage
  • Loading branch information
c-schmitz committed Sep 21, 2020
1 parent 8b4896d commit bb84d20
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions application/models/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,12 @@ public function generateTokens()
return array(0, 0);
}


//Add some criteria to select only the token field
$criteria = $this->getDbCriteria();
$criteria->select = 'token';
$ntresult = $this->findAllAsArray($criteria); //Use AsArray to skip active record creation
// Do NOT replace the following select with ActiveRecord as it uses too much memory
$ntresult=Yii::app()->db->createCommand()->select('token')->from($this->tableName())-> where("token IS NOT NULL and token<>''")->queryColumn();
// select all existing tokens
foreach ($ntresult as $tkrow) {
$existingtokens[$tkrow] = true;
}
// select all existing tokens
foreach ($ntresult as $tkrow) {
$existingtokens[$tkrow['token']] = true;
Expand Down

0 comments on commit bb84d20

Please sign in to comment.