Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
669eaa29
Commit
669eaa29
authored
Nov 03, 2012
by
Nathaniel Catchpole
Browse files
Issue
#1829942
by amateescu: Fixed Cloning an entity query doesn't clone its conditions.
parent
92804b4c
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/lib/Drupal/Core/Entity/Query/QueryBase.php
View file @
669eaa29
...
...
@@ -233,4 +233,10 @@ public function tableSort(&$headers) {
return
$this
;
}
/**
* Makes sure that the Condition object is cloned as well.
*/
function
__clone
()
{
$this
->
condition
=
clone
$this
->
condition
;
}
}
core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php
View file @
669eaa29
...
...
@@ -156,6 +156,20 @@ function testEntityQuery() {
// 15) needs to be set.
$this
->
assertResult
(
1
,
3
,
4
,
5
,
6
,
7
,
9
,
11
,
12
,
13
,
14
,
15
);
// Test cloning of query conditions.
$query
=
$this
->
factory
->
get
(
'test_entity'
)
->
condition
(
"
$figures
.color"
,
'red'
)
->
sort
(
'ftid'
);
$cloned_query
=
clone
$query
;
$cloned_query
->
condition
(
"
$figures
.shape"
,
'circle'
);
// Bit 0 (1, 3, 5, 7, 9, 11, 13, 15) needs to be set.
$this
->
queryResults
=
$query
->
execute
();
$this
->
assertResult
(
1
,
3
,
5
,
7
,
9
,
11
,
13
,
15
);
// No red color has a circle shape.
$this
->
queryResults
=
$cloned_query
->
execute
();
$this
->
assertResult
();
$query
=
$this
->
factory
->
get
(
'test_entity'
);
$group
=
$query
->
orConditionGroup
()
->
exists
(
$greetings
,
'tr'
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment