You are here

function amazons3_update_7200 in AmazonS3 7.2

Enable composer, add a bucket to all URIs, and delete the HTTPS variable.

File

./amazons3.install, line 173
Install, update and uninstall functions for the AmazonS3 module.

Code

function amazons3_update_7200() {
  if (!module_enable(array(
    'composer_manager',
  ))) {
    throw new DrupalUpdateException('Composer Manager could not be enabled.');
  }

  // Run this early so later updates don't fail due to a missing autoloader.
  if (function_exists('drush_composer_manager_write_if_changed')) {
    drush_composer_manager_write_if_changed();
  }
  $bucket = variable_get('amazons3_bucket');
  db_update('file_managed')
    ->condition('uri', 's3://%', 'LIKE')
    ->expression('uri', 'REPLACE(uri, :protocol, :bucket)', array(
    ':protocol' => 's3://',
    ':bucket' => "s3://{$bucket}/",
  ))
    ->execute();
  variable_del('amazons3_https');
}