This happens in admin/reports/status

Catchable fatal error: Argument 1 passed to AmazonS3::__construct() must be an array, string given, called in /Users/joachim/Sites/veto.local/sites/all/modules/amazons3/AmazonS3StreamWrapper.inc on line 788 and defined in /Users/joachim/Sites/veto.local/sites/all/libraries/awssdk/services/s3.class.php on line 423
Call Stack
# Time Memory Function Location
1 0.0007 650200 {main}( ) ../index.php:0
2 0.6824 55760424 menu_execute_active_handler( ) ../index.php:21
3 0.6927 57127808 call_user_func_array ( ) ../menu.inc:503
4 0.6927 57128176 system_status( ) ../menu.inc:503
5 0.9742 64479560 module_invoke_all( ) ../system.admin.inc:2288
6 2.8160 73816600 call_user_func_array ( ) ../module.inc:818
7 2.8160 73817088 xmlsitemap_requirements( ) ../module.inc:818
8 2.8162 73819432 xmlsitemap_check_directory( ) ../xmlsitemap.install:50
9 2.8163 73820248 file_prepare_directory( ) ../xmlsitemap.module:797
10 2.8163 73820472 is_dir ( ) ../file.inc:444
11 2.8163 73822912 AmazonS3StreamWrapper->url_stat( ) ../file.inc:444
12 2.8163 73822912 AmazonS3StreamWrapper->_stat( ) ../AmazonS3StreamWrapper.inc:606
13 2.8163 73823056 AmazonS3StreamWrapper->_is_dir( ) ../AmazonS3StreamWrapper.inc:820
14 2.8164 73823200 AmazonS3StreamWrapper->getS3( ) ../AmazonS3StreamWrapper.inc:899
15 2.8256 74986560 AmazonS3->__construct( ) ../AmazonS3StreamWrapper.inc:788

Comments

boombatower’s picture

Title: Catchable fatal error: Argument 1 passed to AmazonS3::__construct() must be an array, string given » Update to support awssdk 1.5 and/or specify compatible versions.
Project: AWS SDK for PHP » Amazon S3
Version: 7.x-5.0 » 7.x-1.0-alpha1
Category: bug » task

As the release notes indicate the new SDK from Amazon is not backwards compatible. Amazon S3 project should indicate the versions of awssdk it is compatible with and probably add to .info file dependency to ensure people don't enable the wrong one.

Added more explicit note to 1.5 release notes.

hadsie’s picture

Project: Amazon S3 » AmazonS3
Version: 7.x-1.0-alpha1 » 7.x-1.x-dev
Category: task » bug
StatusFileSize
new2.44 KB

Attached is a patch that should hopefully fix the changes caused by the 1.5 sdk.

hadsie’s picture

Status: Active » Needs review
hadsie’s picture

StatusFileSize
new3.4 KB

I had missed some code in the previous patch. Please ignore that one and use this one instead :).

boombatower’s picture

Status: Needs review » Needs work
+++ b/AmazonS3StreamWrapper.inc
@@ -777,7 +777,7 @@ class AmazonS3StreamWrapper implements DrupalStreamWrapperInterface {
+      $secret_key = variable_get('aws_secret', '');

The proper way to do this is CFCredentials::get()->secret as seen https://gist.github.com/1480151. That way people can configure the AWS SDK outside of awssdk project Drupal variables.

In fact I don't think you need to pass the key to the sdk at all it should just pick it up.

+++ b/README
@@ -3,7 +3,7 @@ Installation
-(For installation of awssdk, you will need to download the Amazon SDK for PHP and place it in sites/all/libraries/awdsdk )

Hopefully libraries 2.x will get is UI that will explain all this soon. :)

Powered by Dreditor.

bassplaya’s picture

@ hadsie
I'm having the same issue here and I'm stuck.
I have no clue how a patch gets applied.
Can you explain so I can use this module too? Cheers.

bassplaya’s picture

In the meantime I learnt how to work with git and how to apply a patch. If anyone looking for that. drupal.org/patch is a great resource. Sorry for being so ignorant.
Here's what my terminal window says (MAMP):

BassPlaya:amazons3 GraphicDesign$ git apply -v amazons3-1373768.patch
amazons3-1373768.patch:69: trailing whitespace.
        form_set_error('amazons3_bucket', t('There was a problem with the SSL certificate. Try setting "certificate_authority" to true in libraries/awssdk/config.inc.php'));  
Checking patch AmazonS3StreamWrapper.inc...
Hunk #1 succeeded at 769 (offset -8 lines).
Hunk #2 succeeded at 777 (offset -8 lines).
Checking patch README...
error: README: No such file or directory
Checking patch amazons3.module...
Hunk #1 succeeded at 78 (offset -12 lines).
error: while searching for:
    }
    catch(RequestCore_Exception $e){
      if(strstr($e->getMessage(), 'SSL certificate problem')) {
        form_set_error('amazons3_bucket', t('There was a problem with the SSL certificate. Try setting AWS_CERTIFICATE_AUTHORITY to true in libraries/awssdk/config.inc.php'));  
      }
      else {
        form_set_error('amazons3_bucket', t('There was a problem connecting to S3'));  

error: patch failed: amazons3.module:109
error: amazons3.module: patch does not apply

I hope that you know what this means because I don't.
boombatower replied something as well to your patch I guess but I couldn't figure out what that all meant.
Maybe someone can explain or submit a working patch.
Cheers!

bassplaya’s picture

Ok, I got your patch in #4 (http://drupal.org/comment/reply/1373768/5390154#comment-5390154) running now when I used the dev version of this module but I got an error again saying:

There was a problem using S3

I've seen this mentioned in the lines of your patch somewhere but I have no clue what actually causes this.
Could it be because I'm on a local host (MAMP) instead of on a live server?

justafish’s picture

This needs fixing in the awssdk first http://drupal.org/node/1371444

justafish’s picture

Status: Needs work » Needs review
StatusFileSize
new2.8 KB

and here's the patch against 7.x-1.x-dev to make this module work, but you'll need the one in the above mentioned issue first.

bassplaya’s picture

How come I can't get this patch to apply. Am I the only one?

Here's what I get in Terminal:

BassPlaya:amazons3 GraphicDesign$ drush pmi amazons3
 Project          :  amazons3                                   
 Type             :  module                                     
 Title            :  Amazon S3                                  
 Description      :  Provides S3 stream wrapper class           
 Version          :  7.x-1.x-dev                                
 Package          :  Amazon S3                                  
 Core             :  7.x                                        
 Status           :  enabled                                    
 Path             :  sites/all/modules/amazons3                 
 Schema version   :  module has no schema                       
 Files            :  amazons3.module, AmazonS3StreamWrapper.inc 
 Requires         :  awssdk, libraries                          


BassPlaya:amazons3 GraphicDesign$ git apply -v update1.5.1373768.patch
update1.5.1373768.patch:56: trailing whitespace.
        form_set_error('amazons3_bucket', t('There was a problem with the SSL certificate. Try setting AWS_CERTIFICATE_AUTHORITY to true in "libraries/awssdk/config.inc.php". You may also have a curl library (e.g. the default shipped with MAMP) that does not contain trust certificates for the major authorities.'));  
Checking patch AmazonS3StreamWrapper.inc...
error: while searching for:
   */
  protected function getS3() {
    if($this->s3 == null) {
      $key = variable_get('aws_key', '');
      $secret_key = variable_get('aws_secret_key', '');
      $bucket = variable_get('amazons3_bucket', '');
    
      if(!libraries_load('awssdk') && !isset($key) && !isset($secret_key) && !isset($bucket)) {
        drupal_set_message('Unable to load the AWS SDK. Please check you have installed the library correctly and configured your S3 credentials.'. 'error');
      }
      else {
        try {
         $this->s3 = new AmazonS3($key, $secret_key);
         $this->bucket = $bucket;
        }
        catch(RequestCore_Exception $e){

error: patch failed: AmazonS3StreamWrapper.inc:776
error: AmazonS3StreamWrapper.inc: patch does not apply
Checking patch amazons3.module...
error: while searching for:

function amazons3_admin_validate($form, &$form_state) {
  $bucket = $form_state['values']['amazons3_bucket'];
  $key = variable_get('aws_key', '');
  $secret_key = variable_get('aws_secret_key', '');
  
  if(!libraries_load('awssdk')) {
    form_set_error('amazons3_bucket', t('Unable to load the AWS SDK. Please check you have installed the library correctly and configured your S3 credentials.'));
  }
  else {
    try {
      $s3 = new AmazonS3($key, $secret_key);
      // test connection
      $user_id = $s3->get_canonical_user_id();
      if(!$user_id['id']) {

error: patch failed: amazons3.module:89
error: amazons3.module: patch does not apply
justafish’s picture

Status: Needs review » Closed (fixed)

Patch has been committed, please reopen if there are any problems (you'll still need to apply the awssdk patch first).

Saoirse1916’s picture

Still not working for me. I'm using the Dev versions of awssdk and Amazon S3 and I've patched awssdk with the above patch, cleared caches, deleted everything, ran update.php, cleared caches, reinstalled everything, cleared caches again. No luck and I get the same error as above, which occurs only when I attempt to save my default bucket name in config/media/amazons3.

Saoirse1916’s picture

Status: Closed (fixed) » Active
justafish’s picture

Saoirse1916’s picture

Ah ha, looks like that did it. Thanks a bunch!

jbeckers’s picture

i'm on dev of both awssdk and amazons3.

just did a drush up, updated amazons3 to the latest dev, and everything seems back to normal.

the patch for awssdk seems not to be needed when you're on dev.

jbeckers’s picture

Status: Active » Fixed
justafish’s picture

Status: Fixed » Closed (fixed)

Yep, all patches have been committed, so you just need the latest dev versions of everything and you should be good to go.

Anonymous’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta7
Category: bug » support

I am coming across a similar error.

Argument 1 passed to AmazonS3::__construct() must be an array, string given, called in /Users/chris/webserver/ravelunravel/sites/all/modules/contrib/AmazonS3/amazons3.module on line 66 and defined in AmazonS3->__construct() (line 433 of /Users/chris/webserver/ravelunravel/sites/all/libraries/awssdk/services/s3.class.php).

I've followed examples and tutorials but when I enter the S3 bucket name and save, it returns this error

I'm using SDK 1.5.4.x and Module 7.x-5.3

Anonymous’s picture

After a reinstall of supporting modules fixed the issue.

djake’s picture

Version: 7.x-1.0-beta7 » 7.x-1.x-dev
Status: Closed (fixed) » Active

I am attempting to update form beta7 to dev and am receiving this error. I have recently updated the SDK to 1.6.2, and am running it with beta7, no problem. (I have awssdk for php 5.4. )

Any suggestions? (Apologies if this should be a new issue.)

djake’s picture

Status: Active » Fixed

sorry please ignore prior post

Status: Fixed » Closed (fixed)

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