2009-05-20 Steffen Kamper <info@sk-typo3.de>
+ * Fixed bug #11022: DBAL does not support SQL having "+" (used in cache management)
* Fixed bug #8231: DBAL's bug admin_get_charsets() on a non-object
2009-05-20 Oliver Hader <oliver@typo3.org>
'content',
$this->cacheTable,
'identifier = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($entryIdentifier, $this->cacheTable) . ' '
- . 'AND ((crdate + lifetime) >= ' . time() . ' OR lifetime = 0)'
+ . 'AND (crdate + lifetime >= ' . time() . ' OR lifetime = 0)'
);
if (count($cacheEntries) == 1) {
'content',
$this->cacheTable,
'identifier = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($entryIdentifier, $this->cacheTable) . ' '
- . 'AND (crdate + lifetime) >= ' . time()
+ . 'AND crdate + lifetime >= ' . time()
);
if (count($cacheEntries) == 1) {
$cacheEntryIdentifierRows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
'identifier',
$this->cacheTable,
- $this->getListQueryForTag($tag) . ' AND ((crdate + lifetime) >= ' . time() . ' OR lifetime = 0)'
+ $this->getListQueryForTag($tag) . ' AND (crdate + lifetime >= ' . time() . ' OR lifetime = 0)'
);
foreach ($cacheEntryIdentifierRows as $cacheEntryIdentifierRow) {
foreach ($tags as $tag) {
$whereClause[] = $this->getListQueryForTag($tag);
}
- $whereClause[] = '((crdate + lifetime) >= ' . time() . ' OR lifetime = 0)';
+ $whereClause[] = '(crdate + lifetime >= ' . time() . ' OR lifetime = 0)';
$cacheEntryIdentifierRows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
'identifier',
public function collectGarbage() {
$GLOBALS['TYPO3_DB']->exec_DELETEquery(
$this->cacheTable,
- '(crdate + lifetime) < ' . time()
+ 'crdate + lifetime < ' . time()
);
}
// Find "modifyer", eg. "NOT or !"
$stack[$level][$pnt[$level]]['modifier'] = trim($this->nextPart($parseString,'^(!|NOT[[:space:]]+)'));
+ // Support calculated value only for:
+ // - "&" (boolean AND)
+ // - "+" (addition)
+ // - "-" (substraction)
+ // - "*" (multiplication)
+ // - "/" (division)
+ // - "%" (modulo)
+ $calcOperators = '&|\+|-|\*|\/|%';
+
// Fieldname:
- if ($fieldName = $this->nextPart($parseString,'^([[:alnum:]._]+)([[:space:]]+|&|<=|>=|<|>|=|!=|IS)')) {
+ if ($fieldName = $this->nextPart($parseString, '^([[:alnum:]._]+)([[:space:]]+|' . $calcOperators . '|<=|>=|<|>|=|!=|IS)')) {
// Parse field name into field and table:
$tableField = explode('.',$fieldName,2);
return $this->parseError('No field name found as expected in parseWhereClause()',$parseString);
}
- // See if the value is calculated. Support only for "&" (boolean AND) at the moment:
- $stack[$level][$pnt[$level]]['calc'] = $this->nextPart($parseString,'^(&)');
+ // See if the value is calculated:
+ $stack[$level][$pnt[$level]]['calc'] = $this->nextPart($parseString, '^(' . $calcOperators . ')');
if (strlen($stack[$level][$pnt[$level]]['calc'])) {
// Finding value for calculation:
$stack[$level][$pnt[$level]]['calc_value'] = $this->getValue($parseString);
}
// Detecting the operator for the next level:
- $op = $this->nextPart($parseString,'^(AND[[:space:]]+NOT|OR[[:space:]]+NOT|AND|OR)(\(|[[:space:]]+)');
+ $op = $this->nextPart($parseString, '^(AND[[:space:]]+NOT|&&[[:space:]]+NOT|OR[[:space:]]+NOT|OR[[:space:]]+NOT|\|\|[[:space:]]+NOT|AND|&&|OR|\|\|)(\(|[[:space:]]+)');
if ($op) {
+ // Normalize boolean operator
+ $op = str_replace(array('&&', '||'), array('AND', 'OR'), $op);
$stack[$level][$pnt[$level]]['operator'] = $op;
} elseif (strlen($parseString)) {
/**
* Implodes an array of WHERE clause configuration into a WHERE clause.
*
- * DBAL-specific: The only(!) handled "calc" operator supported by parseWhereClause() is the bitwise
- * logical and (&), and only this one is supported here!
+ * DBAL-specific: The only(!) handled "calc" operators supported by parseWhereClause() are:
+ * - the bitwise logical and (&)
+ * - the addition (+)
+ * - the substraction (-)
+ * - the multiplication (*)
+ * - the division (/)
+ * - the modulo (%)
*
* @param array WHERE clause configuration
* @return string WHERE clause as string.
$output.=' '.trim($v['modifier']).' ';
// DBAL-specific: Set calculation, if any:
- if ($v['calc'] && $functionMapping) {
+ if ($v['calc'] === '&' && $functionMapping) {
switch(true) {
case $GLOBALS['TYPO3_DB']->runningADOdbDriver('oci8'):
// Oracle only knows BITAND(x,y) - sigh