Commit 3b79c810 authored by Stephan Helten's avatar Stephan Helten Committed by Felix Oertel
Browse files

[+BUGFIX] Make $query->equals, no case sensitivity, work with UTF8

Change-Id: Ic00c9bafe6c0ca262fc3f9d716e0dae20d07ead5
Fixes: #27413
Releases: 1.3, 4.7, 4.8
parent 47c1cf7f
......@@ -461,7 +461,11 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
$this->qomFactory->propertyValue($propertyName, $this->getSelectorName())
),
Tx_Extbase_Persistence_QueryInterface::OPERATOR_EQUAL_TO,
strtolower($operand)
t3lib_div::makeInstance('t3lib_cs')->conv_case(
Tx_Extbase_Persistence_QueryInterface::CHARSET,
$operand,
'toLower'
)
);
}
......
......@@ -30,7 +30,6 @@
*
* @package Extbase
* @subpackage Persistence
* @version $Id$
* @api
*/
interface Tx_Extbase_Persistence_QueryInterface {
......@@ -110,6 +109,11 @@ interface Tx_Extbase_Persistence_QueryInterface {
*/
const JCR_JOIN_TYPE_RIGHT_OUTER = '{http://www.jcp.org/jcr/1.0}joinTypeRightOuter';
/**
* Charset of strings in QOM
*/
const CHARSET = 'utf-8';
/**
* Gets the node-tuple source for this query.
*
......
......@@ -127,5 +127,36 @@ class Tx_Extbase_Tests_Unit_Persistence_QueryTest extends Tx_Extbase_Tests_Unit_
$this->query->setOffset(-1);
}
/**
* @return array
*/
public function equalsForCaseSensitiveFalseLowercasesOperandProvider() {
return array(
'Polish alphabet' => array('name', 'ĄĆĘŁŃÓŚŹŻABCDEFGHIJKLMNOPRSTUWYZQXVąćęłńóśźżabcdefghijklmnoprstuwyzqxv', 'ąćęłńóśźżabcdefghijklmnoprstuwyzqxvąćęłńóśźżabcdefghijklmnoprstuwyzqxv' ),
'German alphabet' => array('name', 'ßÜÖÄüöä', 'ßüöäüöä'),
'Greek alphabet' => array('name', 'Τάχιστη αλώπηξ βαφής ψημένη γη', 'τάχιστη αλώπηξ βαφής ψημένη γη'),
'Russian alphabet' => array('name', 'АВСТРАЛИЯавстралия', 'австралияавстралия'),
);
}
/**
* Checks if equals condition makes utf-8 argument lowercase correctly
* @test
* @dataProvider equalsForCaseSensitiveFalseLowercasesOperandProvider
*
* @param string $propertyName The name of the property to compare against
* @param mixed $operand The value to compare with
* @param string $expectedOperand
*/
public function equalsForCaseSensitiveFalseLowercasesOperand($propertyName, $operand, $expectedOperand) {
/** @var $qomFactory Tx_Extbase_Persistence_QOM_QueryObjectModelFactory */
$qomFactory = $this->getMock( 'Tx_Extbase_Persistence_QOM_QueryObjectModelFactory', array('comparison'));
$qomFactory->injectObjectManager(t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager'));
$qomFactory->expects($this->once())->method('comparison')->with($this->anything(), $this->anything(), $expectedOperand);
$this->query->injectQomFactory($qomFactory);
$this->query->equals($propertyName, $operand, FALSE);
}
}
?>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment