You are here

function panopoly_widgets_update_7004 in Panopoly Widgets 7

Implements hook_update_N().

Convert panel panes with "uuid" style subtypes into "fpid" style subtypes.

File

./panopoly_widgets.install, line 187
An installation file for Panopoly Widgets

Code

function panopoly_widgets_update_7004(&$sandbox) {
  $results = db_select('panels_pane', 'p')
    ->fields('p', array(
    'pid',
    'subtype',
  ))
    ->execute()
    ->fetchAll();
  foreach ($results as $result) {
    if (substr($result->subtype, 0, 5) == 'uuid:') {
      $uuid = substr($result->subtype, 5);
      $fpid = db_select('fieldable_panels_panes', 'fpp')
        ->fields('fpp', array(
        'fpid',
      ))
        ->condition('uuid', $uuid)
        ->execute()
        ->fetchField();
      if (!empty($fpid)) {
        $subtype = "fpid:" . $fpid;
        db_update('panels_pane')
          ->fields(array(
          'subtype' => $subtype,
        ))
          ->condition('pid', $result->pid)
          ->execute();
      }
    }
  }
}