You are here

function saml_sp_update_7206 in SAML Service Provider 7.3

Same name and namespace in other branches
  1. 7.2 saml_sp.install \saml_sp_update_7206()

Serialize x509 certs.

File

./saml_sp.install, line 236
Hook_requirements for the SAML Service Provider module.

Code

function saml_sp_update_7206() {
  db_add_field('saml_sp_idps', 'x509_certs', array(
    'description' => 'The x.509 public certificate of the IDP',
    'type' => 'text',
    'not null' => TRUE,
    'initial' => '',
    'serialize' => TRUE,
  ));
  $idps = db_select('saml_sp_idps', 't')
    ->fields('t', array(
    'machine_name',
    'x509_cert',
  ))
    ->execute();
  while ($idp = $idps
    ->fetchAssoc()) {
    $x509_certs = serialize(array(
      $idp['x509_cert'],
    ));
    db_update('saml_sp_idps')
      ->fields(array(
      'x509_certs' => $x509_certs,
    ))
      ->condition('machine_name', $idp['machine_name'])
      ->execute();
  }
  db_drop_field('saml_sp_idps', 'x509_cert');
}