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 f207a15 commit cf1517f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions application/models/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,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['token']] = true;
}
$existingtokens[$tkrow] = true;
}
$newtokencount = 0;
$invalidtokencount = 0;
$newtoken = null;
Expand Down

0 comments on commit cf1517f

Please sign in to comment.