function system_update_7076

Convert menu_links query strings into arrays.

Related topics

File

modules/system/system.install, line 3247

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();
            }
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.