+2010-08-08 Xavier Perseguers <typo3@perseguers.ch>
+
+ * Fixed bug #12535: DAM-related: Element browser crashes as where-clause cannot be parsed
+
2010-07-27 Xavier Perseguers <typo3@perseguers.ch>
* Fixed bug #15160: Queries should only be parsed once
} else {
$output .= $v['calc_value'][1] . $this->compileAddslashes($v['calc_value'][0]) . $v['calc_value'][1];
}
- } elseif (!($GLOBALS['TYPO3_DB']->runningADOdbDriver('oci8') && $v['comparator'] === 'LIKE' && $functionMapping)) {
+ } elseif (!($GLOBALS['TYPO3_DB']->runningADOdbDriver('oci8') && preg_match('/(NOT )?LIKE( BINARY)?/', $v['comparator']) && $functionMapping)) {
$output .= trim(($v['table'] ? $v['table'] . '.' : '') . $v['field']);
}
}
// Set comparator:
if ($v['comparator']) {
+ $isLikeOperator = preg_match('/(NOT )?LIKE( BINARY)?/', $v['comparator']);
switch (TRUE) {
- case ($GLOBALS['TYPO3_DB']->runningADOdbDriver('oci8') && $v['comparator'] === 'LIKE' && $functionMapping):
+ case ($GLOBALS['TYPO3_DB']->runningADOdbDriver('oci8') && $isLikeOperator && $functionMapping):
// Oracle cannot handle LIKE on CLOB fields - sigh
if (isset($v['value']['operator'])) {
$values = array();
$compareValue = ' ' . $v['value']['operator'] . '(' . implode(',', $values) . ')';
} else {
$compareValue = $v['value'][1] . $this->compileAddslashes(trim($v['value'][0], '%')) . $v['value'][1];
+ }
+ if (t3lib_div::isFirstPartOfStr($v['comparator'], 'NOT')) {
+ $output .= 'NOT ';
}
// To be on the safe side
$isLob = TRUE;
}
break;
default:
+ if ($isLikeOperator && $functionMapping) {
+ if ($GLOBALS['TYPO3_DB']->runningADOdbDriver('postgres') ||
+ $GLOBALS['TYPO3_DB']->runningADOdbDriver('postgres64') ||
+ $GLOBALS['TYPO3_DB']->runningADOdbDriver('postgres7') ||
+ $GLOBALS['TYPO3_DB']->runningADOdbDriver('postgres8')) {
+
+ // Remap (NOT)? LIKE to (NOT)? ILIKE
+ // and (NOT)? LIKE BINARY to (NOT)? LIKE
+ switch ($v['comparator']) {
+ // Remap (NOT)? LIKE to (NOT)? ILIKE
+ case 'LIKE':
+ $v['comparator'] = 'ILIKE';
+ break;
+ case 'NOT LIKE':
+ $v['comparator'] = 'NOT ILIKE';
+ break;
+ default:
+ $v['comparator'] = str_replace(' BINARY', '', $v['comparator']);
+ break;
+ }
+ } else {
+ // No more BINARY operator
+ $v['comparator'] = str_replace(' BINARY', '', $v['comparator']);
+ }
+ }
+
$output .= ' ' . $v['comparator'];
// Detecting value type; list or plain:
$expected = 'SELECT * FROM pages WHERE MAX(uid) IN (1,2,3,4)';
$this->assertEquals($expected, $query);
}
+
+ /**
+ * @test
+ * @see http://bugs.typo3.org/view.php?id=12535
+ */
+ public function likeBinaryOperatorIsKept() {
+ $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery(
+ '*',
+ 'tt_content',
+ 'bodytext LIKE BINARY \'test\''
+ ));
+ $expected = 'SELECT * FROM tt_content WHERE bodytext LIKE BINARY \'test\'';
+ $this->assertEquals($expected, $query);
+ }
+
+ /**
+ * @test
+ * @see http://bugs.typo3.org/view.php?id=12535
+ */
+ public function notLikeBinaryOperatorIsKept() {
+ $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery(
+ '*',
+ 'tt_content',
+ 'bodytext NOT LIKE BINARY \'test\''
+ ));
+ $expected = 'SELECT * FROM tt_content WHERE bodytext NOT LIKE BINARY \'test\'';
+ $this->assertEquals($expected, $query);
+ }
}
?>
\ No newline at end of file
$expected = 'SELECT * FROM "fe_users" WHERE \',\'||"usergroup"||\',\' LIKE \'%,10,%\'';
$this->assertEquals($expected, $query);
}
+
+ /**
+ * @test
+ * @see http://bugs.typo3.org/view.php?id=12535
+ */
+ public function likeBinaryOperatorIsRemoved() {
+ $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery(
+ '*',
+ 'tt_content',
+ 'bodytext LIKE BINARY \'test\''
+ ));
+ $expected = 'SELECT * FROM "tt_content" WHERE (dbms_lob.instr("bodytext", \'test\',1,1) > 0)';
+ $this->assertEquals($expected, $query);
+ }
}
?>
\ No newline at end of file
$expected = 'SELECT * FROM "fe_users" WHERE FIND_IN_SET(10, "usergroup") != 0';
$this->assertEquals($expected, $query);
}
+
+ /**
+ * @test
+ * @see http://bugs.typo3.org/view.php?id=12535
+ */
+ public function likeBinaryOperatorIsRemappedToLike() {
+ $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery(
+ '*',
+ 'tt_content',
+ 'bodytext LIKE BINARY \'test\''
+ ));
+ $expected = 'SELECT * FROM "tt_content" WHERE "bodytext" LIKE \'test\'';
+ $this->assertEquals($expected, $query);
+ }
+
+ /**
+ * @test
+ * @see http://bugs.typo3.org/view.php?id=12535
+ */
+ public function notLikeBinaryOperatorIsRemappedToNotLike() {
+ $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery(
+ '*',
+ 'tt_content',
+ 'bodytext NOT LIKE BINARY \'test\''
+ ));
+ $expected = 'SELECT * FROM "tt_content" WHERE "bodytext" NOT LIKE \'test\'';
+ $this->assertEquals($expected, $query);
+ }
+
+ /**
+ * @test
+ * @see http://bugs.typo3.org/view.php?id=12535
+ */
+ public function likeOperatorIsRemappedToIlike() {
+ $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery(
+ '*',
+ 'tt_content',
+ 'bodytext LIKE \'test\''
+ ));
+ $expected = 'SELECT * FROM "tt_content" WHERE "bodytext" ILIKE \'test\'';
+ $this->assertEquals($expected, $query);
+ }
+
+ /**
+ * @test
+ * @see http://bugs.typo3.org/view.php?id=12535
+ */
+ public function notLikeOperatorIsRemappedToNotIlike() {
+ $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery(
+ '*',
+ 'tt_content',
+ 'bodytext NOT LIKE \'test\''
+ ));
+ $expected = 'SELECT * FROM "tt_content" WHERE "bodytext" NOT ILIKE \'test\'';
+ $this->assertEquals($expected, $query);
+ }
}
?>
\ No newline at end of file