Code Duplication    Length = 16-16 lines in 2 locations

admin_pages/events/Events_Admin_Page.core.php 1 location

@@ 2237-2252 (lines=16) @@
2234
        // Delete them all, one query per model.
2235
        foreach ($ids_to_delete as $model_name => $ids) {
2236
            $model = EE_Registry::instance()->load_model($model_name);
2237
            if ($model->has_primary_key_field()) {
2238
                $where_conditions = [
2239
                    $model->primary_key_name() => [
2240
                        'IN',
2241
                        $ids
2242
                    ]
2243
                ];
2244
            } else {
2245
                $where_conditions = [
2246
                    'OR' => []
2247
                ];
2248
                foreach ($ids as $index_primary_key_string) {
2249
                    $keys_n_values = $model->parse_index_primary_key_string($index_primary_key_string);
2250
                    $where_conditions['OR'][ 'AND*' . $index_primary_key_string ] = $keys_n_values;
2251
                }
2252
            }
2253
            if (!$model->delete_permanently(
2254
                [
2255
                    $where_conditions

core/libraries/batch/JobHandlers/ExecuteBatchDeletion.php 1 location

@@ 84-99 (lines=16) @@
81
            if($units_processed < $batch_size){
82
                $model = EE_Registry::instance()->load_model($model_name);
83
                $ids_to_delete_this_query = array_slice($ids, 0, $batch_size, true);
84
                if ($model->has_primary_key_field()) {
85
                    $where_conditions = [
86
                        $model->primary_key_name() => [
87
                            'IN',
88
                            $ids
89
                        ]
90
                    ];
91
                } else {
92
                    $where_conditions = [
93
                        'OR' => []
94
                    ];
95
                    foreach ($ids as $index_primary_key_string) {
96
                        $keys_n_values = $model->parse_index_primary_key_string($index_primary_key_string);
97
                        $where_conditions['OR'][ 'AND*' . $index_primary_key_string ] = $keys_n_values;
98
                    }
99
                }
100
                $deletion_count = $model->delete_permanently(
101
                    [
102
                        $where_conditions