Bug #49177 ยป cache-bugfix-class.t3lib_tstemplate.php.patch
t3lib/class.t3lib_tstemplate.php (working copy) | ||
---|---|---|
)
|
||
);
|
||
} else {
|
||
$dbFields = array(
|
||
'content' => serialize($cc),
|
||
'tstamp' => $GLOBALS['EXEC_TIME']
|
||
);
|
||
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('cache_pagesection', 'page_id=' . intval($GLOBALS['TSFE']->id) . ' AND mpvar_hash=' . $mpvarHash, $dbFields);
|
||
if ($GLOBALS['TYPO3_DB']->sql_affected_rows() == 0) {
|
||
/**
|
||
* update DB-record (if exists) or update it
|
||
*
|
||
* DON'T use this logic:
|
||
* 1. Update DB-record
|
||
* 2. If 0 rows were affected: Insert DB-record
|
||
*
|
||
* This can produce the SQL-error "Duplicate entry '[pageId]-[mpVarHash]' for key 'PRIMARY'", if 0 rows where affected
|
||
* because the DB-record is up-to-date (e.g. because a concurrent request has changed the DB-record already)
|
||
*/
|
||
$dbFields = array();
|
||
$dbFields['content'] = serialize($cc);
|
||
$dbFields['tstamp'] = $GLOBALS['EXEC_TIME'];
|
||
$sqlWhere = 'page_id=' . intval($GLOBALS['TSFE']->id) . ' AND mpvar_hash=' . $mpvarHash;
|
||
$count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('tstamp', 'cache_pagesection', $sqlWhere);
|
||
if($count > 0) {
|
||
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('cache_pagesection', $sqlWhere, $dbFields);
|
||
} else {
|
||
$dbFields['page_id'] = intval($GLOBALS['TSFE']->id);
|
||
$dbFields['mpvar_hash'] = $mpvarHash;
|
||
$GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_pagesection', $dbFields);
|