Not sure how to categorize this issue, as I think it is in large part due to an error on my part. I would be happy to change this from a bug report to something more appropriate.

I updated this module without having read the project page to see that the underlying library was changed and needed to be updated as well. I was supposed to have installed the PHP opencloud library before running this update.

We didn't notice a problem until trying to upload new files, which would cause a server error:
PHP Fatal error: Class 'OpenCloud\\Rackspace' not found in /var/www/drupal-7-22/sites/all/modules/cloud_files/cloud_files.module on line 405

Once I realized that the library needed to be installed, I did so as per the instructions in the README file. The errors are still occuring, and I am unable to reach the cloud files configuration page: [domain_name]/admin/config/media/cloud-files

I can not load the page, and the server log shows the same error when trying to load the page. I have cleared all the caches I can think of, have disabled & re-enabled the module.

It's clear that somehow the updated module is unable to pick up the new library. I have checked that the new library is indeed sitting at sites/all/libraries/php-opencloud/lib/php-opencloud.php

Editing to add: I am also seeing the following message on various other pages on the site:
"The PHP SDK for OpenStack/Rackspace APIs could not be loaded."

Is there some way I can get the module to find the new library? I can edit the database if necessary. Any help would be appreciated.

Thanks.

-dave.

Comments

daveX99’s picture

I have looked into this a bit more closely by trying to load this library via some test code. I have also looked to see that the 'cache_libraries' table is empty, for what that's worth.

Below, I have pasted the return value of:
libraries_load('php-opencloud');

I am not able to see anything wrong -- I'm focused on the path to the library and the specific file. The file is there, the whole directory is owned by apache, the permissions on the lib directory are 775, the permissions on lib/php-opencloud.php are 664.

Am I missing something obvious? A Golden "D'oh!!" award to whoever will kindly point it out to me.

Thanks,
-dave.

Here's the output from libraries_load('php-opencloud');
------------------

Array
(
    [title] => PHP SDK for OpenStack/Rackspace APIs
    [vendor url] => http://php-opencloud.com/
    [download url] => http://php-opencloud.com/
    [version arguments] => Array
        (
            [file] => RELEASENOTES.md
            [pattern] => /[#]* [\d\/]* Version ([\d.]*)/
        )

    [files] => Array
        (
            [php] => Array
                (
                    [lib/php-opencloud.php] => Array
                        (
                        )

                )

        )

    [module] => cloud_files
    [machine name] => php-opencloud
    [name] => php-opencloud
    [path] => 
    [library path] => sites/all/libraries/php-opencloud
    [version callback] => libraries_get_version
    [dependencies] => Array
        (
        )

    [versions] => Array
        (
        )

    [integration files] => Array
        (
        )

    [callbacks] => Array
        (
            [info] => Array
                (
                    [0] => libraries_prepare_files
                )

            [pre-detect] => Array
                (
                )

            [post-detect] => Array
                (
                    [0] => libraries_detect_dependencies
                )

            [pre-dependencies-load] => Array
                (
                )

            [pre-load] => Array
                (
                )

            [post-load] => Array
                (
                )

        )

    [installed] => 
    [version] => 
    [error] => not detected
    [error message] => The version of the <em class="placeholder">php-opencloud</em> library could not be detected.
    [loaded] => 
)
daveX99’s picture

More, again:

I see in the array element ['version arguments'] a reference to a file 'RELEASENOTES.md' and a regex pattern. I'm assuming that this is used to determine the version of the library in question. I can not find that RELEASENOTES.md file anywhere in the new opencloud library.

Is this why it won't load? I'm still looking through this, but don't quite understand how the Libraries API works. Thanks in advanced.

-dave.

jamiehannaford’s picture

Hey Dave,

I work for Rackspace and help manage their PHP SDK. It seems that this module is trying to grab the SDK version from a file called RELEASENOTES.md - which no longer exists.

To get everything working, you have two options:

1. In "cloud_files.module", replace the "version arguments" array key with "version" => '1.6.0'

2. To do something fancier, you can replace the "version arguments" array (in the same file) with:

array(
        'file' => 'lib/OpenCloud/Globals.php',
        'pattern' => '/RAXSDK_VERSION[^\d]+(\d+\.\d+(\.\d+)?)/'
       'lines' => 200
)

Both will work, but the first is quicker because you're effectively hard-coding the version for Drupal. The second solution checks lib/OpenCloud/Globals.php for the version number, and retrieves it with the appropriate regex.

If you need any more help with the PHP SDK or Cloud Files, feel free to give me a shout: jamie.hannaford@rackspace.com

Jamie

daveX99’s picture

Jamie:

Thanks for the tip. I do not want to hack the module in this case. I would urge the developers of the module (or others who might want to roll your suggestion into a patch) to give it a try.

In the time since I opened this issue thread, our shop has decided to discontinue our use of the Rackspace Cloud Files for our sites. It has caused a variety of problems. This is not a direct criticism of either Rackspace or this module, but it has not proven a reliable solution to use this on our Drupal sites.

Our problems may very well have to do with how we have implemented it. In one instance (maybe 2 weeks ago?), there was a system-wide problem with RS Cloud Files, and clicking on a link that relied on getting a file from the CDN would actually cause our server to go down. Again, I suspect that it may be the way we set this up. We can do what we need without relying on this module, so we've rearranged things and disabled the module where it was in use.

I do think however, that the reliance of this module on the existence of a README (or RELEASENOTES, or whatever) file and a regex to determine the version is a bit shaky. If that is the reason the library can't be loaded, it's a real problem.

Any change like this to the library by Rackspace that isn't reflected by an update to the module will break sites that depend on it.

If I should close this thread, please let me know, but I'm inclined to leave it open in case there are any others who have run into this problem.

-dave.

benfreda’s picture

I can confirm that Jamie's fix worked! I just tried it. Thanks Jamie.

Word of warning -- make sure to completely uninstall the module and *clear cache* before you reinstall and retest. Otherwise you might be confused (as I was) as to why the output of libraries_load('php-opencloud') still mentions the "RELEASENOTES.md" file even after you've removed it completely from the module's code.

nathan.bolin’s picture

#3 worked for detecting version. Small syntax error that needs correcting...

'pattern' => '/RAXSDK_VERSION[^\d]+(\d+\.\d+(\.\d+)?)/'

needs comma at the end:

'pattern' => '/RAXSDK_VERSION[^\d]+(\d+\.\d+(\.\d+)?)/',

reszli’s picture

StatusFileSize
new781 bytes

I ran into the same problem with the recommended release
and the dev version is not accessible for download for some reason

following is a patch that combines the above fixes
and made the module for for me!

reszli’s picture

Issue summary: View changes

Edited to include additional error messages displayed on my site.

matthensley’s picture

Note- in recent updates to the php-opencloud library, lib/OpenCloud/Globals.php is removed. This breaks the above patch. Looks like 1.7.0 was the last one that used it.

beanjammin’s picture

In 1.7.2 I'm finding what looks like the library version in /lib/OpenCloud/Common/Http/Client.php which is returned by the function getDefaultUserAgent()

class Client extends GuzzleClient
{
    
    const VERSION = '1.7.0';
    const MINIMUM_PHP_VERSION = '5.3.0';

    public function __construct($url, $options)
    {
        // @codeCoverageIgnoreStart
      if (PHP_VERSION < self::MINIMUM_PHP_VERSION) {
        throw new UnsupportedVersionError(sprintf(
                'You must have PHP version >= %s installed.',
                self::MINIMUM_PHP_VERSION
            ));
        }
        // @codeCoverageIgnoreEnd
    
        parent::__construct($url, $options);
    }
    
    public function getDefaultUserAgent()
    {
        return 'OpenCloud/' . self::VERSION
            . ' cURL/' . CurlVersion::getInstance()->get('version')
            . ' PHP/' . PHP_VERSION;
    }

    public function getUserAgent()
    {
        return $this->userAgent;
    }
    
}
rm-rf’s picture

Issue summary: View changes
StatusFileSize
new753 bytes

Please find attached a patch which will resolve the version as described above.

omnia.ibrahim’s picture

both patchs are not working for me, i have the same errors:

The PHP SDK for OpenStack/Rackspace APIs could not be loaded.

Warning: Invalid argument supplied for foreach() in cloud_files_admin() (line 80 of all/modules/contrib/cloud_files/cloud_files.module).

rm-rf’s picture

Hi omnia,

Path number 8 does work in the sense that it fixes the issue in finding the correct version number. However there appear to be many other things wrong with the code, which it will not fix. I will try to spend some more time debugging this further.

coozila’s picture

The some error i have download the latest librari from git

i have test all patch and not working

The PHP SDK for OpenStack/Rackspace APIs could not be loaded.
Warning: Invalid argument supplied for foreach() in cloud_files_admin() (line 78 of /var/www/html/mysite.com/sites/all/modules/cloud_files/cloud_files.module).
The settings have not been saved because of the errors.

coozila’s picture

Priority: Normal » Critical

No longer works with the new version of api from Rackspace

Kupferman’s picture

StatusFileSize
new636 bytes

It appears they moved the version information to another file. Now it is in the lib/OpenCloud/Version.php file. I got it to work with the attached.

Ok -- ignore my patch. It does make the module re-appear in the configuration area -- but the page is blank. Looks like it is going to take a little more work.

mr.moses’s picture

I've update Cloud Files to work with the most recent version of php-opencloud (1.9.1). Get 7.x-1.2-rc1 to try it out.

The php-opencloud library must be installed with Composer, so run "composer require rackspace/php-opencloud:dev-master" from inside sites/all/libraries/php-opencloud/ and you should be all set.

The Cloud Files module is not really directly dependent on a RELEASENOTES file or whatever, but uses the Libraries module to load the php-opencloud library, which requires version detection on the libraries it loads. I would rather have accurate version detection and not just hard-code something in there to make it work, but that does mean it probably will break again whenever Rackspace decides to move things around again. Frustrating.

Committed in ddc002b.

mr.moses’s picture

Component: Miscellaneous » Code
Status: Active » Needs review

The last submitted patch, 10: cloud_files-2086239-8.patch, failed testing.

ceejay8’s picture

I have the following installed with the below arrangements and it is not working for me;

Cloud Files 7.x-1.2-rc1

Libraries 7.x-2.0+18-dev

Error:

Please make sure the PHP SDK for OpenStack/Rackspace APIs library is installed in the libraries directory (libraries\php-opencloud). (Currently using PHP SDK for OpenStack/Rackspace APIs Failed to load the PHP SDK for OpenStack/Rackspace APIs)

Path to lib:

/var/www/vhosts/domain.com/httpdocs/sites/all/libraries/php-opencloud/lib

Is this correct or am I doing something wrong?

mr.moses’s picture

The php-opencloud library must be installed with Composer, so run "composer require rackspace/php-opencloud:dev-master" from inside sites/all/libraries/php-opencloud/ and you should be all set.

You should end up with something like this: sites/all/libraries/php-opencloud/vendor/rackspace/php-opencloud/lib

ceejay8’s picture

But that's what I've had since I started and it's never worked;

/var/www/vhosts/domain.com/httpdocs/sites/all/libraries/php-opencloud/vendor/rackspace/php-opencloud/lib

# ls -alh
total 16K
drwxr-xr-x 3 domain.com domain.com 4.0K Jan 22 21:36 .
drwxr-xr-x 6 domain.com domain.com 4.0K Jan 22 21:36 ..
drwxr-xr-x 14 domain.com domain.com 4.0K Jan 22 21:36 OpenCloud
-rw-r--r-- 1 domain.com domain.com 51 Jan 22 21:36 php-opencloud.php

Do the directories or the whole website need to be owned by Apache (currently owned by user)? I saw an implementation of Drupal with this setup that worked.

I am using the latest Drupal version - Drupal 7.26. Might it be a caching issue? I clear the cache from within Drupal with the same issue.:-(

mr.moses’s picture

The Libraries module does cache info about the libraries, so if you change the something in the libraries folder you should flush the cache.

Did you install it with Composer? There should be other dependencies installed in the vendor folder (guzzle, symfony, etc.).

The module is actually looking for the Composer generated file, sites/all/libraries/php-opencloud/vendor/autoload.php

ceejay8’s picture

I have all those files you kindly mentioned;

drwxr-xr-x 6 domain.com domain.com 4.0K Jan 22 21:36 .
drwxr-xr-x 4 domain.com domain.com 4.0K Jan 23 06:45 ..
-rw-r--r-- 1 domain.com domain.com 183 Jan 22 21:36 autoload.php
drwxr-xr-x 2 domain.com domain.com 4.0K Jan 22 21:36 composer
drwxr-xr-x 6 domain.com domain.com 4.0K Jan 22 21:36 guzzle
drwxr-xr-x 3 domain.com domain.com 4.0K Jan 22 21:36 rackspace
drwxr-xr-x 3 domain.com domain.com 4.0K Jan 22 21:36 symfony
# pwd
/var/www/vhosts/domain.com/httpdocs/sites/all/libraries/php-opencloud/vendor

Is there anything wrong with my permissions on the files and folders you think?

jamiehannaford’s picture

For those receiving the "Please make sure the PHP SDK for OpenStack/Rackspace APIs library is installed" error message, you will need to follow these steps:

1. Go to ./sites/all/libraries/ and mkdir php-opencloud
2. Inside the php-opencloud dir, install the SDK by following these steps: https://github.com/rackspace/php-opencloud#installation
3. Create a file called php-opencloud.libraries.info in ./sites/all/libraries with this content:

name = php-opencloud
machine name = php-opencloud
description = Rackspace SDK for OpenStack APIs
version = 1.7.2
files[php][] = vendor/autoload.php

And everything should work. Clear all your caches for good measure. For some reason the Libraries API is not auto-detecting the directory (the hook_libraries_info function doesn't seem to be executed); so you have to provide a config file instead. More info here: https://drupal.org/node/1342238

Please note this is a temporary fix - the module owner may need to look into why Drupal is ignoring the `cloud_files_libraries_info` function.

topcweb’s picture

Jamie,
Thanks for the update. I was eventually able to get this to work with this last suggestion. I would emphasize the importance of using composer to complete the API library install. I ended up having to increase my memory limit to above the 128 'max' to get this to work.

mr.moses’s picture

Depending on which version of php-opencloud you have, the version is located in different spots. This causes problems loading the library because the Libraries API requires a version for each library. If it can't find the version, it fails to load the library.

If you create php-opencloud.libraries.info in ./sites/all/libraries, I think its basically hardcoding a version to satisfy the Libraries API. I'm guessing Libraries API doesn't autodetect the version from the php-opencloud library, it just uses whatever you put in the .info (which may be fine, just inaccurate).

The cloud_files_libraries_info hook was working for me locally (Windows 7/XAMPP) with:

  • php-opencloud 1.9.1
  • Cloud Files 7.x-1.2-rc1
  • Libraries 7.x-2.1
  • Drupal 7.26
ceejay8’s picture

Thank you so much Mr Moses. I just came on, saw your instructions and I followed your guide and it is working for me now.

As a further guide to your eloquently made one.

1, Drupal specs: drupal-7.26

Cloud files: 7.x-1.1-beta1

Libraries: 7.x-3.x-dev

2, To clear Drupal cache

Go to Configuration>Performance>Clear all caches

3, To clear all Drupal cache on the server, use Drush;

i, Install Drush (you should have pear installed on the server via SSH)
pear channel-discover pear.drush.org
pear install drush/drush

drush cc all

4, Install composer

curl -sS https://getcomposer.org/installer | php

php composer.phar

mv composer.phar /usr/bin/composer

5, Run composer in your httpdocs/sites/all/libraries/php-opencloud folder;

cd httpdocs/sites/all/libraries/php-opencloud

composer require rackspace/php-opencloud:dev-master

6, Change to one directory level up into libraries/ and create the php-opencloud.libraries.info Mr Moses indicated;

vim httpdocs/sites/all/libraries/php-opencloud.libraries.info

name = php-opencloud
machine name = php-opencloud
description = Rackspace SDK for OpenStack APIs
version = 1.7.2
files[php][] = vendor/autoload.php

Enable the libraries module then the cloud_files module and you're done.;-)

Thanks again for all the help!

iLLin’s picture

Thanks @ceejay8

ceejay8’s picture

My pleasure.;-)

mr.moses’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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