function system_update_7076 in Drupal 7
Convert menu_links query strings into arrays.
Related topics
File
- modules/
system/ system.install, line 3228 - Install, update and uninstall functions for the system module.
Code
function system_update_7076() {
$query = db_select('menu_links', 'ml', array(
'fetch' => PDO::FETCH_ASSOC,
))
->fields('ml', array(
'mlid',
'options',
));
foreach ($query
->execute() as $menu_link) {
if (strpos($menu_link['options'], 'query') !== FALSE) {
$menu_link['options'] = unserialize($menu_link['options']);
if (isset($menu_link['options']['query']) && is_string($menu_link['options']['query'])) {
$menu_link['options']['query'] = drupal_get_query_array($menu_link['options']['query']);
db_update('menu_links')
->fields(array(
'options' => serialize($menu_link['options']),
))
->condition('mlid', $menu_link['mlid'], '=')
->execute();
}
}
}
}