This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /* |
||
3 | * This file is part of EC-CUBE |
||
4 | * |
||
5 | * Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved. |
||
6 | * |
||
7 | * http://www.lockon.co.jp/ |
||
8 | * |
||
9 | * This program is free software; you can redistribute it and/or |
||
10 | * modify it under the terms of the GNU General Public License |
||
11 | * as published by the Free Software Foundation; either version 2 |
||
12 | * of the License, or (at your option) any later version. |
||
13 | * |
||
14 | * This program is distributed in the hope that it will be useful, |
||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
17 | * GNU General Public License for more details. |
||
18 | * |
||
19 | * You should have received a copy of the GNU General Public License |
||
20 | * along with this program; if not, write to the Free Software |
||
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||
22 | */ |
||
23 | |||
24 | |||
25 | namespace Eccube\Repository; |
||
26 | |||
27 | use Doctrine\ORM\EntityRepository; |
||
28 | |||
29 | /** |
||
30 | * NewsRepository |
||
31 | * |
||
32 | * This class was generated by the Doctrine ORM. Add your own custom |
||
33 | * repository methods below. |
||
34 | */ |
||
35 | class NewsRepository extends EntityRepository |
||
36 | { |
||
37 | |||
38 | /** |
||
39 | * News の順位を1上げる. |
||
40 | * |
||
41 | * @param \Eccube\Entity\News $News |
||
42 | * @return boolean 成功した場合 true |
||
43 | */ |
||
44 | 4 | View Code Duplication | public function up(\Eccube\Entity\News $News) |
0 ignored issues
–
show
|
|||
45 | { |
||
46 | 4 | $em = $this->getEntityManager(); |
|
47 | 4 | $em->getConnection()->beginTransaction(); |
|
48 | try { |
||
49 | 4 | $rank = $News->getRank(); |
|
50 | |||
51 | 4 | $News2 = $this->findOneBy(array('rank' => $rank + 1)); |
|
52 | 4 | if (!$News2) { |
|
53 | 1 | throw new \Exception(); |
|
54 | } |
||
55 | 3 | $News2->setRank($rank); |
|
56 | 3 | $em->persist($News2); |
|
57 | |||
58 | // News更新 |
||
59 | 3 | $News->setRank($rank + 1); |
|
60 | |||
61 | 3 | $em->persist($News); |
|
62 | 3 | $em->flush(); |
|
63 | |||
64 | 3 | $em->getConnection()->commit(); |
|
65 | 1 | } catch (\Exception $e) { |
|
66 | 1 | $em->getConnection()->rollback(); |
|
67 | |||
68 | 1 | return false; |
|
69 | } |
||
70 | |||
71 | 3 | return true; |
|
72 | } |
||
73 | |||
74 | /** |
||
75 | * News の順位を1下げる |
||
76 | * |
||
77 | * @param \Eccube\Entity\News $News |
||
78 | * @return boolean 成功した場合 true |
||
79 | */ |
||
80 | 4 | View Code Duplication | public function down(\Eccube\Entity\News $News) |
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
81 | { |
||
82 | 4 | $em = $this->getEntityManager(); |
|
83 | 4 | $em->getConnection()->beginTransaction(); |
|
84 | try { |
||
85 | 4 | $rank = $News->getRank(); |
|
86 | 4 | $News2 = $this->findOneBy(array('rank' => $rank - 1)); |
|
87 | 4 | if (!$News2) { |
|
88 | 1 | throw new \Exception(); |
|
89 | } |
||
90 | 3 | $News2->setRank($rank); |
|
91 | 3 | $em->persist($News2); |
|
92 | |||
93 | // News更新 |
||
94 | 3 | $News->setRank($rank - 1); |
|
95 | |||
96 | 3 | $em->persist($News); |
|
97 | 3 | $em->flush(); |
|
98 | |||
99 | 3 | $em->getConnection()->commit(); |
|
100 | 1 | } catch (\Exception $e) { |
|
101 | 1 | $em->getConnection()->rollback(); |
|
102 | |||
103 | 1 | return false; |
|
104 | } |
||
105 | |||
106 | 3 | return true; |
|
107 | } |
||
108 | |||
109 | /** |
||
110 | * News を保存する. |
||
111 | * |
||
112 | * @param \Eccube\Entity\News $News |
||
113 | * @return boolean 成功した場合 true |
||
114 | */ |
||
115 | 4 | View Code Duplication | public function save(\Eccube\Entity\News $News) |
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
116 | { |
||
117 | 4 | $em = $this->getEntityManager(); |
|
118 | 4 | $em->getConnection()->beginTransaction(); |
|
119 | try { |
||
120 | 4 | if (!$News->getId()) { |
|
121 | 4 | $rank = $this->createQueryBuilder('n') |
|
122 | 4 | ->select('MAX(n.rank)') |
|
123 | 4 | ->getQuery() |
|
124 | 4 | ->getSingleScalarResult(); |
|
125 | 4 | if (!$rank) { |
|
126 | 1 | $rank = 0; |
|
127 | } |
||
128 | $News |
||
129 | 4 | ->setRank($rank + 1) |
|
130 | 4 | ->setDelFlg(0); |
|
131 | } |
||
132 | |||
133 | 4 | $em->persist($News); |
|
134 | 4 | $em->flush(); |
|
135 | 3 | $em->getConnection()->commit(); |
|
136 | 1 | } catch (\Exception $e) { |
|
137 | 1 | $em->getConnection()->rollback(); |
|
138 | 1 | return false; |
|
0 ignored issues
–
show
|
|||
139 | } |
||
140 | |||
141 | 3 | return true; |
|
142 | } |
||
143 | |||
144 | /** |
||
145 | * News を削除する. |
||
146 | * |
||
147 | * @param \Eccube\Entity\News $News |
||
148 | * @return boolean 成功した場合 true |
||
149 | */ |
||
150 | 4 | View Code Duplication | public function delete(\Eccube\Entity\News $News) |
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
151 | { |
||
152 | 4 | $em = $this->getEntityManager(); |
|
153 | 4 | $em->getConnection()->beginTransaction(); |
|
154 | try { |
||
155 | 4 | $rank = $News->getRank(); |
|
156 | 4 | $em->createQueryBuilder() |
|
157 | 4 | ->update('Eccube\Entity\News', 'n') |
|
158 | 4 | ->set('n.rank', 'n.rank - 1') |
|
159 | 4 | ->where('n.rank > :rank')->setParameter('rank', $rank) |
|
160 | 4 | ->getQuery() |
|
161 | 4 | ->execute(); |
|
162 | |||
163 | $News |
||
164 | 4 | ->setDelFlg(1) |
|
165 | 4 | ->setRank(0); |
|
166 | |||
167 | 4 | $em->persist($News); |
|
168 | 4 | $em->flush(); |
|
169 | |||
170 | 3 | $em->getConnection()->commit(); |
|
171 | 1 | } catch (\Exception $e) { |
|
172 | 1 | $em->getConnection()->rollback(); |
|
173 | 1 | return false; |
|
0 ignored issues
–
show
|
|||
174 | } |
||
175 | |||
176 | 3 | return true; |
|
177 | } |
||
178 | } |
||
179 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.