/** * It might be that two (or more) scripts are executed at the same time, * which would lead to a race condition, where both (all) scripts retrieve * the same tokens from the session, so the script that is executed * last will overwrite the tokens generated in the first scripts. * So before writing all tokens back to the session we need to get the * current tokens from the session again. * */ protected function updateTokens() { $this->backendUser->user = $this->backendUser->fetchUserSession(TRUE); $tokens = $this->retrieveTokens(); $this->tokens = array_merge($tokens, $this->addedTokens); foreach ($this->droppedTokenIds as $tokenId) { unset($this->tokens[$tokenId]); } }