Projet

Général

Profil

Révision 136a805a

Ajouté par Assos Assos il y a plus de 7 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/panelizer/panelizer.install
228 228
  }
229 229
}
230 230

  
231
/**
232
 * Implements hook_update_dependencies().
233
 */
234
function panelizer_update_dependencies() {
235
  // Update 7115 requires UUID support in CTools and Panels.
236
  $dependencies['panelizer'][7115] = array(
237
    'panels' => 7302,
238
  );
239

  
240
  return $dependencies;
241
}
242

  
243 231
/**
244 232
 * Implements hook_requirements().
245 233
 */
......
360 348
  }
361 349
}
362 350

  
351
/**
352
 * Implements hook_update_dependencies().
353
 */
354
function panelizer_update_dependencies() {
355
  // Update 7115 requires UUID support in CTools and Panels.
356
  $dependencies['panelizer'][7115] = array(
357
    'panels' => 7302,
358
  );
359

  
360
  // These updates requires Panels storage support, which was added in
361
  // panels_update_7305.
362
  $dependencies['panelizer'][7302] = array(
363
    'panels' => 7305,
364
  );
365
  $dependencies['panelizer'][7303] = array(
366
    'panels' => 7305,
367
  );
368

  
369
  return $dependencies;
370
}
371

  
363 372
/**
364 373
 * Update the panelizer variable to be more feature module friendly.
365 374
 */
......
1151 1160
    // Get a list of all records using a default display.
1152 1161
    $sandbox['max'] = db_query('SELECT COUNT(DISTINCT entity_type) FROM {panelizer_entity} WHERE did = 0')->fetchField();
1153 1162

  
1163
    // Bail if no records found.
1164
    if (empty($sandbox['max'])) {
1165
      return t('No records need to be fixed.');
1166
    }
1167

  
1154 1168
    watchdog('panelizer', 'Default panelizer records will be removed for @count entity types.', array('@count' => $sandbox['max']));
1155 1169
  }
1156 1170

  
......
1216 1230
    return t('There was already an index on the {panelizer_entity} table for the revision_id column, so nothing was done.');
1217 1231
  }
1218 1232
}
1233

  
1234
/**
1235
 * Set the storage type and ID on existing {panelizer_default} records.
1236
 */
1237
function panelizer_update_7302(&$sandbox) {
1238
  if (!isset($sandbox['progress'])) {
1239
    // Initialize batch update information.
1240
    $sandbox['progress'] = (float)0;
1241
    $sandbox['current_did'] = -1;
1242
    $sandbox['max'] = db_query("SELECT COUNT(pd.did)
1243
      FROM {panels_display} pd
1244
        JOIN {panelizer_defaults} p ON p.did = pd.did
1245
      WHERE pd.storage_type = ''")->fetchField();
1246
    if (empty($sandbox['max'])) {
1247
      return t('Nothing to be fixed in Panelizer update 7302.');
1248
    }
1249
  }
1250

  
1251
  // Set a limit of how many rows to process per batch. 1000 rows is probably
1252
  // good.
1253
  $limit = 1000;
1254

  
1255
  // Run the query
1256
  $result = db_query_range("SELECT pd.did, p.name
1257
    FROM {panels_display} pd
1258
      JOIN {panelizer_defaults} p ON p.did = pd.did
1259
    WHERE pd.storage_type = '' AND pd.did > :current_did", 0, $limit, array(':current_did' => $sandbox['current_did']));
1260

  
1261
  foreach ($result as $row) {
1262
    db_update('panels_display')
1263
      ->fields(array(
1264
        'storage_type' => 'panelizer_default',
1265
        'storage_id' => $row->name,
1266
      ))
1267
      ->condition('did', $row->did)
1268
      ->execute();
1269

  
1270
    // Update our progress information.
1271
    $sandbox['progress']++;
1272
    $sandbox['current_did'] = $row->did;
1273
  }
1274

  
1275
  // Set the "finished" status, to tell batch engine whether this function
1276
  // needs to run again.
1277
  $sandbox['#finished'] = ($sandbox['progress'] >= $sandbox['max']) ? TRUE : ($sandbox['progress'] / $sandbox['max']);
1278

  
1279
  if ($sandbox['#finished']) {
1280
    return t('Added the storage type for panelizer_defaults to relevant panels displays');
1281
  }
1282
}
1283

  
1284
/**
1285
 * Set the storage type and ID on existing {panelizer_entity} records.
1286
 */
1287
function panelizer_update_7303(&$sandbox) {
1288
  if (!isset($sandbox['progress'])) {
1289
    // Initialize batch update information.
1290
    $sandbox['progress'] = (float)0;
1291
    $sandbox['current_did'] = -1;
1292
    $sandbox['max'] = db_query("SELECT COUNT(pd.did)
1293
      FROM {panels_display} pd
1294
        JOIN {panelizer_entity} p ON p.did = pd.did
1295
      WHERE pd.storage_type = ''")->fetchField();
1296
    if (empty($sandbox['max'])) {
1297
      return t('Nothing to be fixed in Panelizer update 7303.');
1298
    }
1299
  }
1300

  
1301
  // Set a limit of how many rows to process per batch.
1302
  $limit = 1000;
1303

  
1304
  // Look for records to be updated.
1305
  $result = db_query_range("SELECT pd.did, p.entity_type, p.entity_id, p.view_mode
1306
    FROM {panels_display} pd
1307
      JOIN {panelizer_entity} p ON p.did = pd.did
1308
    WHERE pd.storage_type = '' AND pd.did > :current_did", 0, $limit, array(':current_did' => $sandbox['current_did']));
1309

  
1310
  foreach ($result as $row) {
1311
    db_update('panels_display')
1312
      ->fields(array(
1313
        'storage_type' => 'panelizer_entity',
1314
        'storage_id' => implode(':', array($row->entity_type, $row->entity_id, $row->view_mode)),
1315
      ))
1316
      ->condition('did', $row->did)
1317
      ->execute();
1318

  
1319
    // Update our progress information.
1320
    $sandbox['progress']++;
1321
    $sandbox['current_did'] = $row->did;
1322
  }
1323

  
1324
  // Set the "finished" status, to tell batch engine whether this function
1325
  // needs to run again.
1326
  $sandbox['#finished'] = ($sandbox['progress'] >= $sandbox['max']) ? TRUE : ($sandbox['progress'] / $sandbox['max']);
1327

  
1328
  if ($sandbox['#finished']) {
1329
    return t('Added the storage type for panelizer_entities to relevant panels displays');
1330
  }
1331
}

Formats disponibles : Unified diff