Révision 29771811
Ajouté par Assos Assos il y a presque 5 ans
drupal7/sites/all/modules/media/modules/media_migrate_file_types/includes/media_migrate_file_types.pages.inc | ||
---|---|---|
61 | 61 |
foreach ($migratable_types as $machine_name) { |
62 | 62 |
$type = file_type_load($machine_name); |
63 | 63 |
if (!$type) { |
64 |
$type = new stdClass; |
|
64 |
$type = new stdClass();
|
|
65 | 65 |
$type->label = $type->type = $machine_name; |
66 | 66 |
} |
67 | 67 |
$form['upgradable_types'][$machine_name] = array( |
... | ... | |
137 | 137 |
// Old bundle might be deleted so let's fake some values. |
138 | 138 |
$bundle_old = file_type_load($type); |
139 | 139 |
if (empty($bundle_old)) { |
140 |
$bundle_old = new stdClass; |
|
140 |
$bundle_old = new stdClass();
|
|
141 | 141 |
$bundle_old->type = $type; |
142 | 142 |
$bundle_old->mimetypes = array(); |
143 | 143 |
$bundle_old->export_type = 2; |
... | ... | |
145 | 145 |
|
146 | 146 |
// Migrate fields to new bundle. |
147 | 147 |
if ($_GET['migrate_fields']) { |
148 |
$old_fields = db_select('field_config_instance', 'fc')->fields('fc', array('field_name'))->condition('entity_type', 'file')->condition('bundle', $bundle_old->type)->execute()->fetchCol();
|
|
149 |
$new_fields = db_select('field_config_instance', 'fc')->fields('fc', array('field_name'))->condition('entity_type', 'file')->condition('bundle', $bundle_new->type)->execute()->fetchCol();
|
|
148 |
$old_fields = db_select('field_config_instance', 'fc')->fields('fc', array('field_name'))->condition('entity_type', 'file')->condition('bundle', $bundle_old->type)->execute()->fetchCol(); |
|
149 |
$new_fields = db_select('field_config_instance', 'fc')->fields('fc', array('field_name'))->condition('entity_type', 'file')->condition('bundle', $bundle_new->type)->execute()->fetchCol(); |
|
150 | 150 |
$fields_to_move = array_diff($old_fields, $new_fields); |
151 | 151 |
$fields_to_drop = array_diff($old_fields, $fields_to_move); |
152 | 152 |
|
153 | 153 |
if (!empty($fields_to_move)) { |
154 | 154 |
db_update('field_config_instance') |
155 | 155 |
->fields(array('bundle' => $bundle_new->type)) |
156 |
->condition('entity_type', 'file')
|
|
156 |
->condition('entity_type', 'file') |
|
157 | 157 |
->condition('bundle', $bundle_old->type) |
158 | 158 |
->condition('field_name', $fields_to_move, 'IN') |
159 | 159 |
->execute(); |
... | ... | |
161 | 161 |
|
162 | 162 |
if (!empty($fields_to_drop)) { |
163 | 163 |
db_delete('field_config_instance') |
164 |
->condition('entity_type', 'file')
|
|
164 |
->condition('entity_type', 'file') |
|
165 | 165 |
->condition('bundle', $bundle_old->type) |
166 | 166 |
->condition('field_name', $fields_to_drop, 'IN') |
167 | 167 |
->execute(); |
Formats disponibles : Unified diff
Weekly update of contrib modules