function entity_menu_links_install_revisions in Entity menu links 7
Install initial revisions of existing menu links.
1 call to entity_menu_links_install_revisions()
- entity_menu_links_install in ./
entity_menu_links.install - Implements hook_install().
File
- ./
entity_menu_links.install, line 36
Code
function entity_menu_links_install_revisions() {
$links = drupal_get_schema('menu_links');
$revisions = drupal_get_schema('menu_links_revision');
$rev_fields = $revisions['fields'];
unset($rev_fields['vuuid'], $rev_fields['timestamp'], $rev_fields['vid']);
$links_fields = $links['fields'];
unset($links_fields['uuid'], $links_fields['vid']);
$menu_links_revision_fields = implode(',', array_keys($rev_fields)) . ', timestamp';
$menu_links_fields = implode(',', array_keys($links_fields)) . ', ' . time();
// Add escaping to keyword "external" to fix installation ODBC error with SQL Server d.o issue #2622230.
global $databases;
if (isset($databases['default']['default']['driver']) && $databases['default']['default']['driver'] == 'sqlsrv') {
$menu_links_revision_fields = str_replace('external', '[external]', $menu_links_revision_fields);
$menu_links_fields = str_replace('external', '[external]', $menu_links_fields);
}
$query = "INSERT INTO {menu_links_revision} ({$menu_links_revision_fields}) SELECT {$menu_links_fields} FROM {menu_links} WHERE module = :module";
db_query($query, array(
':module' => 'menu',
));
$query = 'UPDATE {menu_links} SET vid = (SELECT vid FROM {menu_links_revision} WHERE {menu_links}.mlid = mlid) WHERE module = :module';
db_query($query, array(
':module' => 'menu',
));
}