Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
I was trying to install the Facebook PHP sdk through Libraries, and I received this error on the Status report for my site:
Notice: Undefined offset: 1 in libraries_get_version() (line 723 of /path/to/libraries.module).
After looking at the code, I was able to quickly correct this. I've attached a patch. This was problematic in both 7.x-2.0-alpha1 and the dev 2.0 dev version of the module.
Comment | File | Size | Author |
---|---|---|---|
#27 | facebook-library-not-found-1318946-27.patch | 766 bytes | cleaver |
#19 | Screen Shot 2011-12-18 at 5.37.09 PM.png | 50.17 KB | ricardo_reyes |
#15 | facebook-library-not-found-1318946-15.patch | 763 bytes | JamesAn |
#10 | Screen Shot 2011-12-01 at 2.35.48 AM.png | 16.57 KB | ricardo_reyes |
#10 | Screen Shot 2011-12-01 at 2.37.51 AM.png | 87.96 KB | ricardo_reyes |
Comments
Comment #1
giorgio79 CreditAttribution: giorgio79 commentedTested with #1318296: Facebook PHP library not found
Comment #2
amitaibuPatch created to apply to git.
Comment #4
azin CreditAttribution: azin commented#2: 1318946-libraries-offset-2.patch queued for re-testing.
Comment #6
tstoecklerAs you can see by the failing tests, returning
$version[1]
is the expected behaviour. I.e. the pattern you specify for libraries_get_version() should not be the entire version itself, but that should be the first sub-match, i.e. the first pair of parentheses.Looking at the PHPDoc for libraries_get_version, though, that should probably be documented more clearly. The bug lies in the integrating module, though.
I looked at the code, and the following should do:
This is untested, though.
Comment #7
tstoecklerI opened #1323530: Document libraries_get_version() pattern matching more explicitly. for the docs issue in Libraries API. See you there! :)
Comment #8
bryanzera CreditAttribution: bryanzera commentedFixing the pattern per tstoeckler's post worked for us
Comment #9
WhiteX CreditAttribution: WhiteX commentedtstoeckler's method worked here too, but now I got other error :/ (exactly this)
Thanks
Comment #10
ricardo_reyes CreditAttribution: ricardo_reyes commentedtstoeckler et al,
I have edited the fbconnect.module as you explained on post #6. But my drupal system can't find the Facebook PHP sdk.
Do I still have to change the libraries.module to return $version[1]; or retur $version[0]; as others have indicated?
http://drupal.org/files/libraries_offset_fix.patch
If you or anyone please explain the ultimate solution. This forum has too many patches and alternative approaches. Your help is much appreciated.
Thanks.
Comment #11
tstoecklerIn theory my "patch" should be enough to make it work. I didn't test it, though, although for @bryanzera and @WhiteX it seemed to have worked.
Comment #12
FR6 CreditAttribution: FR6 commentedPatch at #6 solved my problem on Drupal 7.9.
Thank you tstoeckler!
Comment #13
stenjo CreditAttribution: stenjo commentedPatch at #6 solved my problem too - using libraries 2.x-dev
Comment #14
JamesAn CreditAttribution: JamesAn commentedI've independently confirmed the proposed fix in #1318946-6: Notice: Undefined offset: 1 in libraries_get_version(). It is indeed a bug in how hook_libraries_info was implemented. (I also agree that the hook_libraries_info documentation still requires you to inspect code and examples to figure it out.)
Details of my explanation can be found at #1318296-25: Facebook PHP library not found. I've marked that issue as a duplicate of this one, since the fix was first proposed here.
Since this bug prevents the module from functioning completely, I'm marking this as major, as recommended in the Issue queue handbook. Yet, I'm attaching a patch, so I hope this issue will get RTBC'd, patched up, and shipped out in a release soon so we can use the module without patching it ourselves.
Comment #15
JamesAn CreditAttribution: JamesAn commented-_- Of course, I forgot to attach the patch. Voila.
Comment #16
jenil27 CreditAttribution: jenil27 commentedI am still getting
Comment #17
csedax90 CreditAttribution: csedax90 commentedsame problem...
Comment #18
danohnesorg CreditAttribution: danohnesorg commentedAlso after commit http://drupalcode.org/project/libraries.git/commit/c5515bd and patch from #6 the SDK seems be found correctly.
Comment #19
ricardo_reyes CreditAttribution: ricardo_reyes commentedI think my only problem now is the facebook-php-skd setup.
Do you have any specific direction on how the libarary should be setup in the Drupal7 structure?
1) sites/all/libraries/facebook-php-sdk/src/facebook.php
or
2) sites/all/modules/libraries/facebook-php-sdk/src/facebook.php
or
3) /sites/all/modules/fbconnect/facebook-php-sdk/src/facebook.php
or
4) ?
Or should the facebook-php-sdk folder be named to "php-sdk" as explained by facebook.
http://developers.facebook.com/docs/reference/php/
Your help is much appreciated.
Comment #20
tstoecklerAccording to the hook_libraries_info() definition 1) should be correct.
Comment #21
bartl CreditAttribution: bartl commented(note: this is a reply to #6)
Pedantically speaking: in your pattern, the dots should be preceded by a backslash. A dot on itself matches any character, while the idea here is to match only dots.
Comment #22
Sjarsena CreditAttribution: Sjarsena commentedthe patch that #6 did worked just take the one from #15 and patch that module. Working with libraries-2.x-dev
Comment #23
xaqrox@19 - Option 1!
Also, the patch in #15 (explained in #6) fixed this for me too. Don't forget to clear your caches!
Comment #24
pointdexter02 CreditAttribution: pointdexter02 commentedI am also getting the error from #16 and #17 above
PHP Fatal error: Call to a member function getUser() on a non-object in sites/all/modules/fbconnect/fbconnect.module on line 408
It happens when I enable the "facebook login" block into a region.
Anybody figure this one out yet?
Comment #25
damien_vancouver CreditAttribution: damien_vancouver commented@Rico6xRico, yes it's option 1. I had to rename my "php-sdk" folder I got by git clone'ing the Facebook library to "facebook-php-sdk" and apply the patch from #15 (and finally clear your caches) before drupal would see the library in my Status report.
It appears many people have reported success here with the patch from #15. I started from scratch today and can verify that it is still an open issue with the latest 7.0-2.0-alpha2 version of Libraries and that the fix still works.
I'm therefore marking this as reviewed & tested by the community, specifically meaning the patch from #15.
Comment #26
tstoecklerNeeds work for that?
Comment #27
cleaver CreditAttribution: cleaver commentedadded the backslashes to the regex
Comment #28
damien_vancouver CreditAttribution: damien_vancouver commentedNew patch from #27 applies cleanly and works for me still. Setting back to reviewed & tested!
Comment #29
inkage CreditAttribution: inkage commentedHi,
Doesn't work for me
> Fresh latest Drupal 7 install
> Got the latest version of dev fbconnect + success patch from 27
> Latest dev version of Librairies
Still not found...
Cheers.
Comment #30
damien_vancouver CreditAttribution: damien_vancouver commented@inkage,
You're correct that the patch no longer works against Libraries v7.x-2.x-dev.
The dreaded "Notice: Undefined offset: 1 in libraries_get_version()" error message has returned.
A Workaround: You can download and install Libraries 7.x-2.0-alpha2, and then the patch from #27 should work. (remember your Facebook SDK must be named "facebook-php-sdk", ie. sites/all/libraries/facebook-php-sdk )
Meanwhile, we must make this work against the Libraries -dev. Setting back to needs work.
Comment #31
inkage CreditAttribution: inkage commented@damnien
Cheers, working by changing the lib, thanks mate !
> I just don't have the button displaying in the default logging box now :/
Thanks again.
Comment #32
cjs_ CreditAttribution: cjs_ commentedNot sure what to do at this point.
Have applied the latest patch to libraries.module and fbconnect.module, flushed cache, disabled both libraries and fbconnect and re-enabled, flushed cache again.
Retried this several times to no avail. Still get the undefined getUser() and status report shows Facebook SDK not found.
facebook.php and base_facebook.php reside in
/sites/all/libraries/facebook-php-sdk/src/
Can't seem to make any headway getting this fixed.
Libraries is the alpha version, btw.
Comment #33
cleaver CreditAttribution: cleaver commented@cjs, I applied the patch in this thread and *not* the libraries module patch. I think the libraries patch (changing to index 0) was just a hack to work around this bug.
Comment #34
buhbuhbuhbowser CreditAttribution: buhbuhbuhbowser commentedI'm having the problem too...not that that's unique. I'm wondering how the patch should be applied? Should I paste it into my libraries.module file?
My error is this: Call to a member function getLoginUrl() on a non-object in /home/content/84/8138184/html/sites/all/modules/fbconnect/fbconnect.pages.inc on line 231, but I'm assuming its just a manifestation of the same one. And when I go to the status page it says that facebook php sdk is not installed.
Comment #35
ofktoubro CreditAttribution: ofktoubro commentedApplying patches is
patch -b < filename.patch
Look here: http://www.brightlemon.com/blog/applying-patches-drupal or do a search for more...
Comment #36
ofktoubro CreditAttribution: ofktoubro commentedPatch in #27 applied to D7.10 with fbconnect 7.x-2.x-dev AND libraries 7.x-2.0-alpha2.
It now finds the fb library at sites/all/libraries/facebook-php-sdk
Tnx tstoeckler, JamesAn and cleaver
Comment #37
buhbuhbuhbowser CreditAttribution: buhbuhbuhbowser commentedPatch in #27 worked, thank you all, and thanks ofktoubro for telling me how to patch. My sanity depends on people like you.
When I installed the libraries module, i stuck the folder inside sites/all/modules, but now when I put the facebook API i need to put it inside sites/all/libraries? I made a copy of the libraries module, but this just confuses me a bit.
Comment #38
cleaver CreditAttribution: cleaver commentedIf this is working for people, please review and set status to RTBC.
Comment #39
NVaissaud CreditAttribution: NVaissaud commentedI confirm #33.
I applied the patch #27 and *not* the libraries module patch (keep version of libraries alpha2 to 1) and it finally works.
Comment #40
tstoecklerAlso note that currently the dev release is exactly the same as alpha2 so it really is basically impossible that that is the cause of any problems. Libraries API also has tests and such, but as of now, there isn't a byte of difference...
Comment #41
juggernautsei CreditAttribution: juggernautsei commentedHi,
I am new here and trying to follow the flow of the conversation. I applied the patch to my new drupal install of 7.12 and my code is reading this in the fbconnect.module:
function fbconnect_libraries_info() {
// Returns an associative array, with information about external library
$libraries['facebook-php-sdk'] = array(
'name' => 'Facebook PHP SDK',
'vendor url' => 'https://github.com/facebook/php-sdk',
'download url' => 'https://github.com/facebook/php-sdk/tarball/v3.1.1',
'version arguments' => array(
'file' => 'readme.md',
// Best practice: Document the actual version strings for later reference.
// 3.1.1: Facebook PHP SDK (v.3.1.1), filters for 3.x.x versions
'pattern' => '/Facebook PHP SDK \(v\.(3\.\d\.\d)\)/',
'lines' => 10,
),
// supported library version, including relevant files
'versions' => array(
'v.3.1.1' => array(
'files' => array(
'php' => array(
'src/base_facebook.php',
'src/facebook.php',
),
),
),
),
);
return $libraries;
Is this correct?
I am still getting this:
Fbconnect 7.x-2.x-dev Allows users to connect with Facebook account
Requires: Libraries (missing)
Required by: Facebook Friends Invite (disabled), FBConnect Test (disabled)
Thanks for any help.
Sherwin
Comment #42
tstoeckler'versions' => array(
'v.3.1.1' => array(
'files' => array(
needs to be
'versions' => array(
'3.1.1' => array(
'files' => array(
Btw, I'm now officially unsubscribing from this issue. If there is any further problem with Libraries API please open a new issue in the queue there.
Comment #43
jcisio CreditAttribution: jcisio commentedRTBC #27
Comment #44
jcisio CreditAttribution: jcisio commented