govCMS / GovCMS7

Current stable release of the main Drupal 7 GovCMS distribution, with releases mirrored at https://www.drupal.org/project/govcms
https://www.govcms.gov.au/
GNU General Public License v2.0
113 stars 76 forks source link

[GOVCMSD7-293]Module admin_views update #896

Closed suhyeonh closed 4 years ago

suhyeonh commented 4 years ago

admin_views 7.x-1.7

Release notes Fix for SA-CONTRIB-2019-076

pandaskii commented 4 years ago

Code looks good but needs more GovCMS testing cases passed before getting merged

/**
 * Remove deprecated views_plugin_access_menu plugin.
 */
function admin_views_update_7100() {
  $result = db_query("SELECT vid, id, display_options FROM {views_display}");
  foreach ($result as $record) {
    $options = unserialize($record->display_options);
    if (isset($options['access']) && is_array($options['access']) && isset($options['access']['type']) && $options['access']['type'] === 'menu') {
      $options['access'] = array(
        'type' => 'perm',
        'perm' => 'access administration pages',
      );

      db_query("UPDATE {views_display} SET display_options = :options WHERE vid = :vid AND id = :id", array(
        'vid' => $record->vid,
        'id' => $record->id,
        'options' => serialize($options),
      ));
    }
  }
}
pandaskii commented 4 years ago

CI is freezing, will re-run it