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.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | cloud_files-2086239-14.patch | 636 bytes | Kupferman |
| #10 | cloud_files-2086239-8.patch | 753 bytes | rm-rf |
Comments
Comment #1
daveX99 commentedI 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');
------------------
Comment #2
daveX99 commentedMore, 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.
Comment #3
jamiehannaford commentedHey 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:
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
Comment #4
daveX99 commentedJamie:
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.
Comment #5
benfreda commentedI 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.
Comment #6
nathan.bolin commented#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+)?)/',Comment #7
reszliI 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!
Comment #7.0
reszliEdited to include additional error messages displayed on my site.
Comment #8
matthensley commentedNote- 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.
Comment #9
beanjammin commentedIn 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()
Comment #10
rm-rf commentedPlease find attached a patch which will resolve the version as described above.
Comment #11
omnia.ibrahim commentedboth 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).
Comment #12
rm-rf commentedHi 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.
Comment #13
coozila commentedThe 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.
Comment #14
coozila commentedNo longer works with the new version of api from Rackspace
Comment #15
Kupferman commentedIt 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.
Comment #16
mr.moses commentedI'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.
Comment #17
mr.moses commentedComment #19
ceejay8 commentedI 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?
Comment #20
mr.moses commentedThe 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
Comment #21
ceejay8 commentedBut 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.:-(
Comment #22
mr.moses commentedThe 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
Comment #23
ceejay8 commentedI 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?
Comment #24
jamiehannaford commentedFor 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:
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.
Comment #25
topcweb commentedJamie,
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.
Comment #26
mr.moses commentedDepending 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:
Comment #27
ceejay8 commentedThank 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!
Comment #28
iLLin commentedThanks @ceejay8
Comment #29
ceejay8 commentedMy pleasure.;-)
Comment #30
mr.moses commented