Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
38d05708
Commit
38d05708
authored
Nov 15, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed unlink() for array valued attributes
return value would not be a valid array when json encoded after unlink(). fixes #6065
parent
e5b92724
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
1 deletion
+27
-1
CHANGELOG.md
extensions/elasticsearch/CHANGELOG.md
+1
-0
BaseActiveRecord.php
framework/db/BaseActiveRecord.php
+1
-1
ActiveRecordTest.php
tests/unit/extensions/elasticsearch/ActiveRecordTest.php
+25
-0
No files found.
extensions/elasticsearch/CHANGELOG.md
View file @
38d05708
...
...
@@ -5,6 +5,7 @@ Yii Framework 2 elasticsearch extension Change Log
-----------------------
-
Bug #5662: Elasticsearch AR updateCounters() now uses explicitly
`groovy`
script for updating making it compatible with ES >1.3.0 (cebe)
-
Bug #6065:
`ActiveRecord::unlink()`
was failing in some situations when working with relations via array valued attributes (cebe)
2.0.0 October 12, 2014
...
...
framework/db/BaseActiveRecord.php
View file @
38d05708
...
...
@@ -1295,7 +1295,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
if
((
$key
=
array_search
(
$model
->
$a
,
$this
->
$b
,
false
))
!==
false
)
{
$values
=
$this
->
$b
;
unset
(
$values
[
$key
]);
$this
->
$b
=
$values
;
$this
->
$b
=
array_values
(
$values
)
;
}
}
else
{
$this
->
$b
=
null
;
...
...
tests/unit/extensions/elasticsearch/ActiveRecordTest.php
View file @
38d05708
...
...
@@ -813,6 +813,31 @@ class ActiveRecordTest extends ElasticSearchTestCase
}
/**
* https://github.com/yiisoft/yii2/issues/6065
*/
public
function
testArrayAttributeRelationUnLinkBrokenArray
()
{
/* @var $order Order */
$order
=
Order
::
find
()
->
where
([
'id'
=>
1
])
->
one
();
$itemIds
=
$order
->
itemsArray
;
$removeId
=
reset
(
$itemIds
);
$item
=
Item
::
get
(
$removeId
);
$order
->
unlink
(
'itemsByArrayValue'
,
$item
);
$this
->
afterSave
();
$items
=
$order
->
itemsByArrayValue
;
$this
->
assertEquals
(
1
,
count
(
$items
));
$this
->
assertFalse
(
isset
(
$items
[
$removeId
]));
// check also after refresh
$this
->
assertTrue
(
$order
->
refresh
());
$items
=
$order
->
itemsByArrayValue
;
$this
->
assertEquals
(
1
,
count
(
$items
));
$this
->
assertFalse
(
isset
(
$items
[
$removeId
]));
}
/**
* @expectedException \yii\base\NotSupportedException
*/
public
function
testArrayAttributeRelationUnLinkAll
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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