Projet

Général

Profil

Révision 599a39cd

Ajouté par Assos Assos il y a environ 3 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/date/date.install
14 14
    case 'datestamp':
15 15
      $db_columns['value'] = array(
16 16
        'type' => 'int',
17
        'size' => 'big',
17 18
        'not null' => FALSE,
18 19
        'sortable' => TRUE,
19 20
        'views' => TRUE,
......
41 42
        'sortable' => TRUE,
42 43
        'views' => TRUE,
43 44
      );
44
      break;
45 45
  }
46 46

  
47 47
  // If a second date is needed for 'End date', make a copy of the first one.
......
51 51
    // We don't want Field API to create additional columns, just the first.
52 52
    // We modify them our own way in views data.
53 53
    $db_columns['value2']['views'] = FALSE;
54

  
55
    // Create a compound index on value and value2 and an index on value2.
56
    $indexes = array(
57
      'value' => array('value', 'value2'),
58
      'value2' => array('value2'),
59
    );
60
  }
61
  else {
62
    // Otherwise just an index on value.
63
    $indexes = array('value' => array('value'));
54 64
  }
55 65
  // Timezone and offset columns are used only if date-specific dates are used.
56 66
  if (isset($field['settings']['tz_handling']) && $field['settings']['tz_handling'] == 'date') {
......
72 82
        'type' => 'int',
73 83
        'not null' => FALSE,
74 84
        'sortable' => TRUE,
75
        'views' => FALSE
85
        'views' => FALSE,
76 86
      );
77 87
    }
78 88
  }
......
84 94
      'views' => FALSE,
85 95
    );
86 96
  }
87
  return array('columns' => $db_columns);
97
  return array('columns' => $db_columns, 'indexes' => $indexes);
88 98
}
89 99

  
90 100
/**
......
134 144
  $query->condition(db_or()->condition('fc.type', 'date')->condition('fc.type', 'datestamp')->condition('fc.type', 'datetime'));
135 145
  $results = $query->execute();
136 146

  
147
  $allowed_types = array(
148
    'date_popup_repeat',
149
    'date_text_repeat',
150
    'date_select_repeat',
151
  );
137 152
  foreach ($results as $record) {
138 153
    $instance = unserialize($record['data']);
139
    if (in_array($instance['widget']['type'], array(
140
        'date_popup_repeat',
141
        'date_text_repeat',
142
        'date_select_repeat'
143
      ))) {
154
    if (in_array($instance['widget']['type'], $allowed_types)) {
144 155
      $instance['widget']['type'] = str_replace('_repeat', '', $instance['widget']['type']);
145 156
      db_update('field_config_instance')
146 157
        ->fields(array(
......
212 223
  // @see https://www.drupal.org/node/1355256
213 224
  date_update_7004();
214 225
}
226

  
227
/**
228
 * Add date value indexes to existed field tables.
229
 */
230
function date_update_7006() {
231
  // Get all fields provided by the Data module.
232
  $query = db_select('field_config', 'f')
233
    ->fields('f', array('id', 'field_name', 'data'))
234
    ->condition('f.type', array('datetime', 'date', 'datestamp'));
235

  
236
  // Special handling for the Encrypt module.
237
  if (module_exists('field_encrypt')) {
238
    $query->condition('f.data', '%' . db_like(' field_encrypt";a:1:{s:7:"encrypt";i:0 ') . '%', 'LIKE');
239
  }
240

  
241
  // Complete the query.
242
  $fields = $query->execute()->fetchAllAssoc('id');
243

  
244
  foreach ($fields as $id => $info) {
245
    $field_info = field_info_field($info->field_name);
246

  
247
    // Add indexes only for SQL storage fields.
248
    if ($field_info['storage']['type'] != 'field_sql_storage') {
249
      continue;
250
    }
251

  
252
    $tables = array(
253
      key($field_info['storage']['details']['sql']['FIELD_LOAD_CURRENT']),
254
      key($field_info['storage']['details']['sql']['FIELD_LOAD_REVISION']),
255
    );
256

  
257
    $data = unserialize($info->data);
258
    $field_name = $info->field_name . '_value';
259
    $field_name2 = $info->field_name . '_value2';
260

  
261
    // Build indexes.
262
    $indexes = $data['indexes'] = array();
263
    if (!empty($data['settings']['todate'])) {
264
      $indexes[$field_name] = array($field_name, $field_name2);
265
      $indexes[$field_name2] = array($field_name2);
266
      $data['indexes']['value'] = array('value', 'value2');
267
      $data['indexes']['value2'] = array('value2');
268
    }
269
    else {
270
      $indexes[$field_name] = array($field_name);
271
      $data['indexes']['value'] = array('value');
272
    }
273

  
274
    // Add missed indexes to tables.
275
    foreach ($indexes as $name => $index) {
276
      foreach ($tables as $table) {
277
        if (!db_index_exists($table, $name)) {
278
          db_add_index($table, $name, $index);
279
        }
280
      }
281
    }
282

  
283
    // Fix date fields storage 'field_config' indexes.
284
    db_update('field_config')
285
      ->fields(array('data' => serialize($data)))
286
      ->condition('id', $id)
287
      ->execute();
288
  }
289
}
290

  
291
/**
292
 * Update datestamp field schema to use 'big' integers.
293
 */
294
function date_update_7007() {
295
  $fields = field_read_fields(array('type' => 'datestamp'));
296
  foreach ($fields as $field_name => $field) {
297
    foreach (array_intersect_key($field['columns'], drupal_map_assoc(array('value', 'value2'))) as $column_name => $schema) {
298
      $schema['size'] = 'big';
299
      $column = $field_name . '_' . $column_name;
300
      if (db_table_exists('field_data_' . $field_name)) {
301
        db_change_field('field_data_' . $field_name, $column, $column, $schema);
302
      }
303
      if (db_table_exists('field_revision_' . $field_name)) {
304
        db_change_field('field_revision_' . $field_name, $column, $column, $schema);
305
      }
306
    }
307
  }
308
}
309

  
310
/**
311
 * The date_migrate_example module was renamed.
312
 */
313
function date_update_7200() {
314
  db_delete('system')->condition('name', 'date_migrate_example')->execute();
315
}

Formats disponibles : Unified diff