Skip to content

Commit

Permalink
FIx an edge-case with variables, where cached data matched against in…
Browse files Browse the repository at this point in the history
…correct submission values
  • Loading branch information
engram-design committed Aug 28, 2024
1 parent 4e76dfb commit 2143dbd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/helpers/Variables.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,16 @@ public static function getParsedValue(mixed $value, Submission $submission = nul
// Parse aliases and env variables
$value = App::parseEnv($value);

// Use a cache key based on the submission, or few unsaved submissions, the formId
// Use a cache key based on the submission, or for unsaved submissions - the formId.
// Be sure to prefix things by what they are to prevent ID collision between form/submission elements.
// This helps to only cache it per-submission, when being run in queues.
$cacheKey = $submission->id ?? $form->id ?? mt_rand();
$cacheKey = mt_rand();

if ($submission->id) {
$cacheKey = 'submission' . $submission->id;
} else if ($form->id) {
$cacheKey = 'form' . $form->id;
}

// Check to see if we have these already calculated for the request and submission
// Just saves a good bunch of calculating values like looping through fields
Expand Down

0 comments on commit 2143dbd

Please sign in to comment.