Skip to content

Commit a0913f5

Browse files
committed
Fixed TaggableQueryBehavior::allTagNames bug
1 parent 3765efe commit a0913f5

File tree

2 files changed

+57
-3
lines changed

2 files changed

+57
-3
lines changed

src/TaggableBehavior.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function getTagNames($asArray = null)
8686
*/
8787
public function setTagNames($names)
8888
{
89-
$this->_tagNames = array_unique($this->filterTagNames($names));
89+
$this->_tagNames = $this->filterTagNames($names);
9090
}
9191

9292
/**
@@ -207,11 +207,11 @@ public function beforeDelete()
207207
*/
208208
public function filterTagNames($names)
209209
{
210-
return preg_split(
210+
return array_unique(preg_split(
211211
'/\s*,\s*/u',
212212
preg_replace('/\s+/u', ' ', is_array($names) ? implode(',', $names) : $names),
213213
-1,
214214
PREG_SPLIT_NO_EMPTY
215-
);
215+
));
216216
}
217217
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,58 @@
11
<?php
22

33
return array (
4+
0 =>
5+
array (
6+
'id' => 2,
7+
'title' => 'Post title 2',
8+
'body' => 'Post body 2',
9+
'tags' =>
10+
array (
11+
0 =>
12+
array (
13+
'id' => 2,
14+
'name' => 'tag2',
15+
'frequency' => 2,
16+
),
17+
1 =>
18+
array (
19+
'id' => 3,
20+
'name' => 'tag3',
21+
'frequency' => 3,
22+
),
23+
2 =>
24+
array (
25+
'id' => 4,
26+
'name' => 'tag4',
27+
'frequency' => 2,
28+
),
29+
),
30+
),
31+
1 =>
32+
array (
33+
'id' => 3,
34+
'title' => 'Post title 3',
35+
'body' => 'Post body 3',
36+
'tags' =>
37+
array (
38+
0 =>
39+
array (
40+
'id' => 3,
41+
'name' => 'tag3',
42+
'frequency' => 3,
43+
),
44+
1 =>
45+
array (
46+
'id' => 4,
47+
'name' => 'tag4',
48+
'frequency' => 2,
49+
),
50+
2 =>
51+
array (
52+
'id' => 5,
53+
'name' => 'tag5',
54+
'frequency' => 1,
55+
),
56+
),
57+
),
458
);

0 commit comments

Comments
 (0)