Conditions | 46 |
Paths | > 20000 |
Total Lines | 191 |
Code Lines | 93 |
Lines | 55 |
Ratio | 28.8 % |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
139 | function moduleUpdate() |
||
140 | { |
||
141 | $oDB = &DB::getInstance(); |
||
142 | $oModuleModel = getModel('module'); |
||
143 | $oModuleController = getController('module'); |
||
144 | |||
145 | // 2007. 7. 25: Add a column(notify_message) for notification |
||
146 | if(!$oDB->isColumnExists("documents","notify_message")) |
||
147 | { |
||
148 | $oDB->addColumn('documents',"notify_message","char",1); |
||
149 | } |
||
150 | |||
151 | // 2007. 8. 23: create a clustered index in the document table |
||
152 | if(!$oDB->isIndexExists("documents","idx_module_list_order")) |
||
153 | { |
||
154 | $oDB->addIndex("documents","idx_module_list_order", array("module_srl","list_order")); |
||
155 | } |
||
156 | |||
157 | if(!$oDB->isIndexExists("documents","idx_module_update_order")) |
||
158 | { |
||
159 | $oDB->addIndex("documents","idx_module_update_order", array("module_srl","update_order")); |
||
160 | } |
||
161 | |||
162 | if(!$oDB->isIndexExists("documents","idx_module_readed_count")) |
||
163 | { |
||
164 | $oDB->addIndex("documents","idx_module_readed_count", array("module_srl","readed_count")); |
||
165 | } |
||
166 | |||
167 | if(!$oDB->isIndexExists("documents","idx_module_voted_count")) |
||
168 | { |
||
169 | $oDB->addIndex("documents","idx_module_voted_count", array("module_srl","voted_count")); |
||
170 | } |
||
171 | // 2007. 10. 17 Add a trigger to delete all posts together when the module is deleted |
||
172 | View Code Duplication | if(!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after')) |
|
173 | $oModuleController->insertTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after'); |
||
174 | // 2007. 10. 25 add columns(parent_srl, expand) |
||
175 | if(!$oDB->isColumnExists("document_categories","parent_srl")) $oDB->addColumn('document_categories',"parent_srl","number",12,0); |
||
176 | if(!$oDB->isColumnExists("document_categories","expand")) $oDB->addColumn('document_categories',"expand","char",1,"N"); |
||
177 | if(!$oDB->isColumnExists("document_categories","group_srls")) $oDB->addColumn('document_categories',"group_srls","text"); |
||
178 | // 2007. 11. 20 create a composite index on the columns(module_srl + is_notice) |
||
179 | if(!$oDB->isIndexExists("documents","idx_module_notice")) $oDB->addIndex("documents","idx_module_notice", array("module_srl","is_notice")); |
||
180 | |||
181 | // 2007. 12. 03: Add if the colume(extra_vars) doesn't exist |
||
182 | if(!$oDB->isColumnExists("documents","extra_vars")) $oDB->addColumn('documents','extra_vars','text'); |
||
183 | |||
184 | // 2008. 02. 18 create a composite index on the columns(module_srl + document_srl) (checked by Manian)) |
||
185 | if(!$oDB->isIndexExists("documents","idx_module_document_srl")) $oDB->addIndex("documents","idx_module_document_srl", array("module_srl","document_srl")); |
||
186 | // 2008. 04. 23 Add a column(blamed count) |
||
187 | View Code Duplication | if(!$oDB->isColumnExists("documents", "blamed_count")) |
|
188 | { |
||
189 | $oDB->addColumn('documents', 'blamed_count', 'number', 11, 0, true); |
||
190 | $oDB->addIndex('documents', 'idx_blamed_count', array('blamed_count')); |
||
191 | } |
||
192 | |||
193 | if(!$oDB->isIndexExists("documents","idx_module_blamed_count")) |
||
194 | { |
||
195 | $oDB->addIndex('documents', 'idx_module_blamed_count', array('module_srl', 'blamed_count')); |
||
196 | } |
||
197 | |||
198 | if(!$oDB->isColumnExists("document_voted_log", "point")) |
||
199 | $oDB->addColumn('document_voted_log', 'point', 'number', 11, 0, true); |
||
200 | |||
201 | |||
202 | if(!$oDB->isColumnExists("document_categories","color")) $oDB->addColumn('document_categories',"color","char",7); |
||
203 | |||
204 | // 2009. 01. 29: Add a column(lang_code) if not exist in the document_extra_vars table |
||
205 | if(!$oDB->isColumnExists("document_extra_vars","lang_code")) $oDB->addColumn('document_extra_vars',"lang_code","varchar",10); |
||
206 | |||
207 | // 2009. 01. 29 Added a trigger for additional setup |
||
208 | View Code Duplication | if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before')) |
|
209 | $oModuleController->insertTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before'); |
||
210 | // 2009. 03. 09 Add a column(lang_code) to the documnets table |
||
211 | if(!$oDB->isColumnExists("documents","lang_code")) |
||
212 | { |
||
213 | $db_info = Context::getDBInfo(); |
||
214 | $oDB->addColumn('documents',"lang_code","varchar",10, $db_info->lang_code); |
||
215 | $obj->lang_code = $db_info->lang_type; |
||
|
|||
216 | executeQuery('document.updateDocumentsLangCode', $obj); |
||
217 | } |
||
218 | // 2009. 03. 11 Check the index in the document_extra_vars table |
||
219 | View Code Duplication | if(!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars")) |
|
220 | { |
||
221 | $oDB->addIndex("document_extra_vars", "unique_extra_vars", array("module_srl","document_srl","var_idx","lang_code"), true); |
||
222 | } |
||
223 | |||
224 | if($oDB->isIndexExists("document_extra_vars", "unique_module_vars")) |
||
225 | { |
||
226 | $oDB->dropIndex("document_extra_vars", "unique_module_vars", true); |
||
227 | } |
||
228 | |||
229 | // 2009. 03. 19: Add a column(eid) |
||
230 | // 2009. 04. 12: Fixed the issue(#17922959) that changes another column values when adding eid column |
||
231 | View Code Duplication | if(!$oDB->isColumnExists("document_extra_keys","eid")) |
|
232 | { |
||
233 | $oDB->addColumn("document_extra_keys","eid","varchar",40); |
||
234 | |||
235 | $output = executeQuery('document.getGroupsExtraKeys', $obj); |
||
236 | if($output->toBool() && $output->data && count($output->data)) { |
||
237 | foreach($output->data as $extra_keys) { |
||
238 | $args->module_srl = $extra_keys->module_srl; |
||
239 | $args->var_idx = $extra_keys->idx; |
||
240 | $args->new_eid = "extra_vars".$extra_keys->idx; |
||
241 | $output = executeQuery('document.updateDocumentExtraKeyEid', $args); |
||
242 | } |
||
243 | } |
||
244 | } |
||
245 | |||
246 | View Code Duplication | if(!$oDB->isColumnExists("document_extra_vars","eid")) |
|
247 | { |
||
248 | $oDB->addColumn("document_extra_vars","eid","varchar",40); |
||
249 | $obj->var_idx = '-1,-2'; |
||
250 | $output = executeQuery('document.getGroupsExtraVars', $obj); |
||
251 | if($output->toBool() && $output->data && count($output->data)) |
||
252 | { |
||
253 | foreach($output->data as $extra_vars) |
||
254 | { |
||
255 | $args->module_srl = $extra_vars->module_srl; |
||
256 | $args->var_idx = $extra_vars->idx; |
||
257 | $args->new_eid = "extra_vars".$extra_vars->idx; |
||
258 | $output = executeQuery('document.updateDocumentExtraVarEid', $args); |
||
259 | } |
||
260 | } |
||
261 | } |
||
262 | |||
263 | // 2011. 03. 30 Cubrid index Check the index in the document_extra_vars table |
||
264 | View Code Duplication | if(!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order")) |
|
265 | { |
||
266 | $oDB->addIndex("document_extra_vars", "idx_document_list_order", array("document_srl","module_srl","var_idx"), false); |
||
267 | } |
||
268 | |||
269 | //2011. 04. 07 adding description column to document categories |
||
270 | if(!$oDB->isColumnExists("document_categories","description")) $oDB->addColumn('document_categories',"description","varchar",200,0); |
||
271 | |||
272 | //2011. 05. 23 adding status column to document |
||
273 | if(!$oDB->isColumnExists('documents', 'status')) |
||
274 | { |
||
275 | $oDB->addColumn('documents', 'status', 'varchar', 20, 'PUBLIC'); |
||
276 | $args->is_secret = 'Y'; |
||
277 | $output = executeQuery('document.updateDocumentStatus', $args); |
||
278 | } |
||
279 | |||
280 | // 2011. 09. 08 drop column document is_secret |
||
281 | if($oDB->isColumnExists('documents', 'status') && $oDB->isColumnExists('documents', 'is_secret')) |
||
282 | $oDB->dropColumn('documents', 'is_secret'); |
||
283 | |||
284 | //2011. 06. 07 merge column, allow_comment and lock_comment |
||
285 | if($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment')) |
||
286 | { |
||
287 | $oDB->addColumn('documents', 'comment_status', 'varchar', 20, 'ALLOW'); |
||
288 | |||
289 | $args->commentStatus = 'DENY'; |
||
290 | |||
291 | // allow_comment='Y', lock_comment='Y' |
||
292 | $args->allowComment = 'Y'; |
||
293 | $args->lockComment = 'Y'; |
||
294 | $output = executeQuery('document.updateDocumentCommentStatus', $args); |
||
295 | |||
296 | // allow_comment='N', lock_comment='Y' |
||
297 | $args->allowComment = 'N'; |
||
298 | $args->lockComment = 'Y'; |
||
299 | $output = executeQuery('document.updateDocumentCommentStatus', $args); |
||
300 | |||
301 | // allow_comment='N', lock_comment='N' |
||
302 | $args->allowComment = 'N'; |
||
303 | $args->lockComment = 'N'; |
||
304 | $output = executeQuery('document.updateDocumentCommentStatus', $args); |
||
305 | } |
||
306 | |||
307 | if($oDB->isColumnExists('documents', 'allow_comment') && $oDB->isColumnExists('documents', 'comment_status')) |
||
308 | $oDB->dropColumn('documents', 'allow_comment'); |
||
309 | |||
310 | if($oDB->isColumnExists('documents', 'lock_comment') && $oDB->isColumnExists('documents', 'comment_status')) |
||
311 | $oDB->dropColumn('documents', 'lock_comment'); |
||
312 | |||
313 | if(!$oDB->isIndexExists("documents", "idx_module_status")) |
||
314 | $oDB->addIndex("documents", "idx_module_status", array("module_srl","status")); |
||
315 | |||
316 | // 2012. 02. 27 Add a trigger to copy extra keys when the module is copied |
||
317 | View Code Duplication | if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after')) |
|
318 | { |
||
319 | $oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after'); |
||
320 | } |
||
321 | |||
322 | // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied |
||
323 | View Code Duplication | if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after')) |
|
324 | { |
||
325 | $oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after'); |
||
326 | } |
||
327 | |||
328 | return new Object(0,'success_updated'); |
||
329 | } |
||
330 | |||
373 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.