Problem/Motivation

HTTP 500 errors and PHP Fatal error: Class 'Aws\S3\StreamWrapper' not found in /var/www/html/sites/all/modules/contrib/s3fs/S3fsStreamWrapper.inc on line 28

Attempting to install S3FS v3 with AWS SDK v3, but am unable to get anywhere. Attempting to uninstall the module results in the same.

Steps to reproduce

Install S3FS module

Unzip the AWS.zip into /sites/all/libraries/awssdk as per documentation https://git.drupalcode.org/project/s3fs/-/blob/7.x-3.x/README.txt

Enable module, enables successfully.

Attempt to access anything, shown the error.

Any insight would be greatly appreciated.

Comments

mcdoolz created an issue. See original summary.

mcdoolz’s picture

So it seems that the module is not loading because the libraries info is seeking the version of the library at the wrong line.

sgdev’s picture

Try to clear your cache first. If you added the SDK and immediately tried to load the module, it's probably not yet available in your system yet, and you'd get a "not found" error.

mcdoolz’s picture

/**
 * Implements hook_libraries_info().
 */
function s3fs_libraries_info() {
  return array(
    'awssdk' => array(
      'title' => 'AWS SDK for PHP',
      'vendor url' => 'http://docs.aws.amazon.com/aws-sdk-php/guide/latest/index.html',
      'download url' => 'https://github.com/aws/aws-sdk-php/releases',
      'version arguments' => array(
        'file' => 'Aws/Sdk.php',
        'pattern' => "/const VERSION = '(.*)';/",
        'lines' => 500,
      ),
      'files' => array(
        'php' => array(
          'aws-autoloader.php',
        ),
      ),
    ),
  );
}

This block looks at line 500. The lines as of the latest SDK needs to be 520.

sgdev’s picture

Title: PHP Fatal error: Class 'Aws\S3\StreamWrapper' not found » Increase library version line check
Status: Active » Needs review
StatusFileSize
new681 bytes

There you go, attached patch should take care of it.

mcdoolz’s picture

Yay community ❤️

sgdev’s picture

@mcdoolz, if the patch meets your needs you should mark it as "Reviewed & tested by the community". Thanks.

mikeytown2’s picture

hard failure on install kinda sucks. Could we drop this from the info file

; Includes
files[] = S3fsStreamWrapper.inc

and then do the include in the .module if the library is there and the correct version is there, etc?

mcdoolz’s picture

Status: Needs review » Reviewed & tested by the community

Sorry for the late response; that works 👍
Also, I agree with mikeytown2; I think having the file included within the module allows devs to provide feedback (should the file not exist), on steps the user can take to rectify the issue.

sgdev’s picture

@mikeytown2, I agree the hard failure is not great, but I think this would be more involved than just moving the include and checking the library. Also, this particular problem can be avoided by using composer instead of the Libraries module.

Libraries is a bit problematic with s3fs, and is part of the reason composer was added to 3.x. There is a special function in the module to load the library, since anyone using Libraries can run into a situation where failures to load are cached, and it becomes nearly impossible to get AWS to load cleanly:

This function is a replacement for calling libraries_load('awssdk'). ... 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.

As well, since s3fs is taking over the file system and the stream wrapper replaces public://, there's most likely going to be some type of hard failure if the library is missing. For such a solution to work seamlessly, I believe there would need to be a fallback to using the default Drupal file system.

I'm certainly open to discussing further and investigating options. This issue was due to not searching far enough in the AWS file to find the version. It was previously a 500 line limit, and AWS recently adjusted their code where const version moved from line 490 to 520. Setting at line 1000 should take care of this particular problem for the remainder of 7.x's life cycle.

joshmiller’s picture

Yay, community seconded. Have a great holiday season, everyone!

mile23’s picture

+1 on the fact that #5 works to take away the error.

  • ram4nd committed e2549f8 on 7.x-3.x authored by ron_s
    Issue #3191113 by ron_s, mcdoolz, Mile23: Increase library version line...
ram4nd’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.