function _s3fs_load_awssdk_library in S3 File System 7.3
Loads the AWS SDK library.
This function is a replacement for calling libraries_load('awssdk'). It's needed because libraries_load() caches failures to load the library, meaning that temporarily having a bad setup (e.g. nonexistent or unreadable files in the awssdk folder) can lead to the library being permanently unable to be loaded, even after the bad setup is repaired. This can only be remedied by clearing the full site cache.
This is especially disastrous when upgrading the AWS SDK library on a system that is currently using it, because if the upgrade results in a bad setup, the site cache may become impossible to clear. If some other module's data has been cached in S3 (e.g. ctools css cache), the cache clearing process itself will attempt to use S3FS. But if the Libraries cache has not yet been cleared by this time, it will continue to insist that AWS SDK is not installed, and the cache clear will crash because s3fs can't function without the AWS SDK library. This leaves the site in an unrecoverable broken state.
Return value
array The array returned by libraries_load('awssdk'), as if it used no cache.
2 calls to _s3fs_load_awssdk_library()
- S3fsStreamWrapper.inc in ./
S3fsStreamWrapper.inc - Drupal stream wrapper implementation for S3 File System.
- _s3fs_get_amazons3_client in ./
s3fs.module - Sets up the S3Client object.
File
- ./
s3fs.module, line 882 - Hook implementations and other primary functionality for S3 File System.
Code
function _s3fs_load_awssdk_library() {
// Start by calling libraries_load().
$library = libraries_load('awssdk');
// If it detects and loads the library, great! We're done.
if (!empty($library['loaded'])) {
return $library;
}
// Otherwise, clear the awssdk value from the Libraries cache, erase the
// static data for libraries_load(), then call it again to get the real
// state of the library.
cache_clear_all('awssdk', 'cache_libraries');
drupal_static_reset('libraries_load');
return libraries_load('awssdk');
}