Skip to content

Instantly share code, notes, and snippets.

@labboy0276
Created August 23, 2014 16:25
Show Gist options
  • Save labboy0276/4f4b8fde628482e8f1cc to your computer and use it in GitHub Desktop.
Save labboy0276/4f4b8fde628482e8f1cc to your computer and use it in GitHub Desktop.
//Hunt and peck other FPP settings and change them to default language
$tables = db_query('SHOW TABLES')->fetchAll();
foreach($tables as $table) {
$key = key($table);
$tablename = $table->$key;
$tocheck = db_field_exists($tablename, 'entity_type');
$tocheck2 = db_field_exists($tablename, 'language');
if ($tocheck && $tocheck2) {
if (strpos($tablename, 'field_data_field') !== false) {
$fpp = db_select($tablename, 't')
->fields('t')
->condition('language', 'und')
->condition('entity_type', 'fieldable_panels_pane')
->execute()
->fetchAll();
if (count($fpp) > 0) {
foreach ($fpp as $key) {
$eid = $key->entity_id;
db_update($tablename)
->fields(array('language' => 'en'))
->condition('entity_id', $eid)
->execute();
$revision = str_replace('field_data', 'field_revision', $tablename);
db_update($revision)
->fields(array('language' => 'en'))
->condition('entity_id', $eid)
->execute();
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment