Code Duplication    Length = 8-9 lines in 2 locations

includes/librairies/install.class.php 2 locations

@@ 431-439 (lines=9) @@
428
                                    $query = $wpdb->prepare("SELECT MAX(position) AS position FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d", $entity_id, $attribute_set_id, $attribute_set_section_id);
429
                                    $last_position = $wpdb->get_var($query);
430
                                    $position = (int) $last_position + 1;
431
                                    foreach ($set_group_infos_details as $attribute_code) {
432
                                        $query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s AND entity_id = %d", $attribute_code, $entity_id);
433
                                        $attribute_id = $wpdb->get_row($query);
434
435
                                        if ($attribute_id->id > 0) {
436
                                            $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $entity_id, 'attribute_set_id' => $attribute_set_id, 'attribute_group_id' => $attribute_set_section_id, 'attribute_id' => $attribute_id->id, 'position' => $position));
437
                                            $position++;
438
                                        }
439
                                    }
440
                                }
441
442
                            }
@@ 539-546 (lines=8) @@
536
                                        $query = $wpdb->prepare("SELECT MAX(position) AS position FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d", $entity_id, $attribute_set_id, $attribute_set_section_id);
537
                                        $last_position = $wpdb->get_var($query);
538
                                        $position = (int) $last_position + 1;
539
                                        foreach ($set_group_infos_details as $attribute_code) {
540
                                            $query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s AND entity_id = %d", $attribute_code, $entity_id);
541
                                            $attribute_id = $wpdb->get_var($query);
542
                                            if ($attribute_id > 0) {
543
                                                $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $entity_id, 'attribute_set_id' => $attribute_set_id, 'attribute_group_id' => $attribute_set_section_id, 'attribute_id' => $attribute_id, 'position' => $position));
544
                                                $position++;
545
                                            }
546
                                        }
547
                                    }
548
                                }
549
                            }