[[!FormIt? &hooks=`redirect` &validate=`donation_type:required, amount:required` &store=`1` &storeTime=`1200` &redirectTo=`2` ]]
[[!FormItRetriever]] [[!FormIt? &submitVar=`regular-donation` &hooks=`redirect` &store=`1` &validate=`nospam:blank,email:email:required,DonorTitle:required,Donor_FirstName:required,Donor_LastName:required` &redirectTo=`4` ]]
[[!FormItRetriever]] [[!FormIt? &submitVar=`dd_donation` &hooks=`email,redirect` &validate=`nospam:blank,email:email:required,DonorTitle:required,Donor_FirstName:required,Donor_LastName:required,Donation_Frequency:required` &emailTpl=`regular_donation_emailTpl` &emailTo=`[email protected]` &redirectTo=`5` ]]
This question has been answered by BobRay. See the first response.
{$context+key}/elements/formit/submission/{$md5_hash}
$data
public function retrieve() { $cacheKey = $this->formit->getStoreKey(); return $this->modx->cacheManager->get($cacheKey); }
public function retrieve() { sleep(3); /* add this line */ $cacheKey = $this->formit->getStoreKey(); $modx->log(modX::LOG_LEVEL_ERROR, 'FormIt CacheKey: ' . $cacheKey); /* And this line */ return $this->modx->cacheManager->get($cacheKey); }
You could try this to see if it's a timing problem. The cache file may not be written fast enough to be there when FormIt retriever tries to get it (though that seems unlikely).
In the file: core\components\formit\model\formit\fidictionary.class.php
around line 138, find this code:
public function retrieve() { $cacheKey = $this->formit->getStoreKey(); return $this->modx->cacheManager->get($cacheKey); }
Change it to:
public function retrieve() { sleep(3); /* add this line */ $cacheKey = $this->formit->getStoreKey(); $modx->log(modX::LOG_LEVEL_ERROR, 'FormIt CacheKey: ' . $cacheKey); /* And this line */ return $this->modx->cacheManager->get($cacheKey); }
The second added line is so you can look in the Error Log and see if the key stays the same (it should).
If that solves it, try sleep(1). If it doesn't solve the problem, remove the extra lines. If it does, just remove the error log line.
public function retrieve() { sleep(3); /* add this line */ $cacheKey = $this->formit->getStoreKey(); return $this->modx->cacheManager->get($cacheKey); }
$this->modx->log(modX::LOG_LEVEL_ERROR, 'FormIt CacheKey: ' . $cacheKey); /* And this line */
Looking at the code, I found that CacheManager locks the file with flock while writing to it and implements a 1-second delay before retrying if it can't obtain the lock. Maybe the cache file is not unlocked in time for the retrieval. Maybe the cache file is also being updated (and locked again) at some other point during the process.
I couldn't find the relevant get() function to see how it handles locked files and whether it has a built-in delay and retry.
From my reading, file locking is a black art that almost no one understands completely.