1 | <?php |
||||
2 | |||||
3 | namespace Elgg\Discussions\Upgrades; |
||||
4 | |||||
5 | use \Elgg\Upgrade\Batch; |
||||
6 | use \Elgg\Upgrade\Result; |
||||
7 | use \Elgg\Database\Update; |
||||
8 | |||||
9 | /** |
||||
10 | * Migrate 'object', 'discussion_reply' to 'object', 'comment' |
||||
11 | * |
||||
12 | * @since 3.0 |
||||
13 | */ |
||||
14 | class MigrateDiscussionReply implements Batch { |
||||
15 | |||||
16 | /** |
||||
17 | * {@inheritDoc} |
||||
18 | */ |
||||
19 | public function getVersion() { |
||||
20 | return 2017112800; |
||||
21 | } |
||||
22 | |||||
23 | /** |
||||
24 | * {@inheritDoc} |
||||
25 | */ |
||||
26 | public function shouldBeSkipped() { |
||||
27 | return empty($this->countItems()); |
||||
28 | } |
||||
29 | |||||
30 | /** |
||||
31 | * {@inheritDoc} |
||||
32 | */ |
||||
33 | public function countItems() { |
||||
34 | |||||
35 | $hidden = access_show_hidden_entities(true); |
||||
36 | |||||
37 | $count = elgg_get_entities([ |
||||
38 | 'type' => 'object', |
||||
39 | 'subtype' => 'discussion_reply', |
||||
40 | 'count' => true, |
||||
41 | ]); |
||||
42 | |||||
43 | access_show_hidden_entities($hidden); |
||||
44 | |||||
45 | return $count; |
||||
1 ignored issue
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||||
46 | } |
||||
47 | |||||
48 | /** |
||||
49 | * {@inheritDoc} |
||||
50 | */ |
||||
51 | public function needsIncrementOffset() { |
||||
52 | return false; |
||||
53 | } |
||||
54 | |||||
55 | /** |
||||
56 | * {@inheritDoc} |
||||
57 | */ |
||||
58 | public function run(Result $result, $offset) { |
||||
59 | |||||
60 | $qb = Update::table('entities', 'e') |
||||
61 | ->set('e.subtype', '"comment"') |
||||
62 | ->where('e.subtype = "discussion_reply"'); |
||||
63 | |||||
64 | $count = $qb->execute(); |
||||
65 | |||||
66 | $result->addSuccesses($count); |
||||
0 ignored issues
–
show
It seems like
$count can also be of type Doctrine\DBAL\Driver\Statement ; however, parameter $num of Elgg\Upgrade\Result::addSuccesses() does only seem to accept integer , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
67 | |||||
68 | return $result; |
||||
69 | } |
||||
70 | } |
||||
71 |