Fatal error: Call to undefined function libraries_get_path() in F:\www\drupal7\sites\all\modules\views_slideshow\contrib\views_slideshow_cycle\views_slideshow_cycle.module on line 13

So I updated Views slideshow today and got this problem.
When I try update.php, it informs me that I libraries is missing so I downloaded libraries module and paste it on modules.
I tried update.php again and the problem with libraries is now gone and I can continue to update but still the problem above persist.
I rollback my Views Slideshow from my backup for now.

Comments

solution for me right now is to make sure that libraries module is enabled first before updating.

Having the same issue! I will try to downgrade to the previous slideshow version, first enable the libraries module (& install) than update the module again. This is a pretty major bug? Are more people experiencing the same problem?

Tested (see post #2) and this worked.
On the notes page of 7.x-3.x-alpha1 you will find that they warn you for this problem http://drupal.org/node/1090018
I guess you should always first read the release notes.
Though the new implementation of drupal 7 to download the newest version (of your modules) makes it easier to download but you will skip the notes a lot faster.
Haha, though master... Always read the notes for dev modules :P

I don't get your solution very well. I'm just amateur for Drupal and English language. Did you mean I should replace views_slideshow 7.x-3.0-alpha1 with 7.x-3.x-dev? Now I can't do anything with my website except by FileZilla. Please help me I don't want to mistake again.

Title:Error on views_slideshow_cycle.module line 13 after updating from latest dev (March 12)Fatal error: Call to undefined function libraries_get_path() in home/views_slideshow/contrib/views_slideshow_cycle/views_slidesh
Assigned:Unassigned» anusornwebsite
Priority:Normal» Critical

Fatal error: Call to undefined function libraries_get_path() in /home/sitename/public_html/sites/all/modules/views_slideshow/contrib/views_slideshow_cycle/views_slideshow_cycle.module on line 13
This is my problem and I used FileZilla to replace views_slideshow 7.x-3.0-alpha1 by 7.x-3.x-dev but it isn't work. I have still this problem. Please help me right now.

Hi anusornwebsite,
first of all: you can always go back to the earlier version module (views_slideshow 7.x-3.0-alpha1) by replacing the new one with the old.
It's OK that you uploaded with filezilla.

After you downgraded to the alpha version, install & active the following module: http://drupal.org/project/libraries (this is new in the 7.x-3.x-dev version)
Than you should empty your cache http://yoursite.com/admin/config/development/performance
That should work.

Hope this helps.
Please let me know if it helped and if it did not help.

Thank you :D

Status:Active» Fixed

Yes Please read the release notes before upgrading. Even if you use the update functionality in drupal 7. Libraries module is REQUIRED before upgrading.

Priority:Critical» Normal

I followed your suggest by replacing the new one with the old. and I installed "libraries" in site/all/. it's not work and try to installed "libraries" in site/all/modules/. It's still not work. finally, I decided to delete views_slideshow it's ok.
I don't remember when I first installed views_slideshow but I won't install it again

thank you for your suggestion

Questions to others:
- is this a good solution? should the database be updated?
- is the libaries a libary or a module?

thanks for anwsering

@thedayway Follow these steps

1) Open up contrib/views_slideshow_cycle/views_slideshow_cycle.module
2) Comment out lines 13 and 19 It should have libraries_get_path in those lines
3) Download http://drupal.org/project/libraries
4) Enable that module
5) Uncomment lines 13 and 19

It should then be fine.

#10 works perfectly, thanks.

same. #10 works perfectly, thanks.

#10 works but it is not a pretty solution, is it?

No it isn't, but I hope people will read the release notes before upgrading. Or read the big bolded text on the project page.

Thanks redndahead,
appreciate the fix and I will be more deligent about reading release notes in the future

Going through the steps in #10 fixed the problem for me -- but I had the libraries module enabled before the upgrade and it was in use by other modules.

thanks .it worked for me

Thanks it worked for me too, but it nearly killed my faint heart ;-)
I was upgrading with drush, so not even thought in looking to the release notes.
Is there any chance to send a message during a drush update or install?

redndahead,

You could put some code similar to the following to prevent the issue:

/**
* Implements hook_init().
*/
function views_slideshow_init() {
  if (!module_exists('libraries')) {
    module_enable(array('libraries'));
    if (!module_exists('libraries')) {
      drupal_set_message(t('Views Slideshow has been disabled as the required !libraries module is not present.', array('!libraries' => l(t('Libraries API'), 'http://drupal.org/project/libraries'))), 'error');
      module_disable(array('views_slideshow'));
    }
  }
}

That way Views Slideshow will look for Libraries, try to enable it if it isn't already enabled, and if that doesn't work it will set an error and disabled Views Slideshow. Might help.

I committed a change where it won't load the javascript if libraries doesn't exist. I didn't want to throw an error on the page directly. If someone sees the slideshow isn't working they will more than likely go to the settings page of the view where they can see the error.

Status:Fixed» Closed (fixed)

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

Hi,

That happened to me the same ... succeeded in restoring the system to delete modules View, views_slideshow y folder libraries
then returned to copy the original folders in /sites/all/libraries and /sites/all/modules/view and views_slideshow

#10 Thanks so much!

Status:Closed (fixed)» Active

Hello,

There is no acceptable fix at the moment.
Asking the admin to install libraries BEFORE putting views_slideshow files on the server is not a fix, and this requirement cannot always be fulfilled. First use case is when you deliver an update with those two modules, and an automated procedure to update the website.
Second one (which I am facing now) is when you have a whole Drupal tree automatically built (think Drush make), and then begin installing a profile which requires both modules, and you're screwed with a WSOD.
Third one I just thought about: copy both modules to your Drupal files, install Views Slideshow via modules pages ; the 'Library' dependency should be automatically installed, but it is too late, hook_requirements will fail with a WSOD.
I suggest writing a patch that at least makes the code safe (in case Libraries module is not installed), and at best provides an alternative way to check the existence of the library.

I'll provide the patch in some time.

David

Status:Active» Needs review
StatusFileSize
new855 bytes

And here is the patch, on 7.x-3.x-dev.

Assigned:anusornwebsite» Unassigned

Still not working on 3.x-dev, so upping here. :)

I would also really like to see the hook_requirements code fixed. Here is a patch that builds on the one provided by David Stosik. It partly borrows from the Superfish module in that it first checks that the Libraries module is present at all. It the maintainers can commit this patch then we can close this issue and #1499552: Call to undefined function _views_slideshow_cycle_pause_libary_path().

Thanks

Status:Needs review» Needs work

Quick review:

+++ contrib/views_slideshow_cycle/views_slideshow_cycle.installundefined
@@ -6,24 +6,45 @@
+      $requirements['views_slideshow_cycle'] = array(

The requirement key should be related to the actual requirement, not the module requiring it, this allows for multiple modules to share a single requirement instead of multiple entires in the status report.

+++ contrib/views_slideshow_cycle/views_slideshow_cycle.installundefined
@@ -6,24 +6,45 @@
+      if (!function_exists('libraries_get_path')) {
+        include_once drupal_get_path('module', 'libraries') . '/libraries.module';

The first check should return after the Libraries module wasn't found so to prevent the need for this check.

@Deciphered.

Thanks for reviewing the patch.

Regarding the key name, I understand what you're saying but how do you construct a key that will be common to all modules requiring the libraries module? Is there a convention? What would you suggest as a key? "jquery.cycle"?

If I understand your second point correctly, you are saying that there is no point in checking for the existence of the libraries_get_path function if the path to the libraries module cannot be found. I believe that is how the patch logic is structured. The second check is required to bootstrap the libraries module because during site installation it won't yet be available to the hook_requirements function.

Either way, I believe the patch solves the problem that currently exists when performing site installs that depend on this module.

'libraries' would be the obvious one.

As for the second point, if you stick a return inside the first check for the Libraries module it will prevent the code executing further if the libraries module doesn't exist, in which case if it where to get to the second condition it's clear that the module does exists, in which case the if statement isn't required, so you can simple do the include without the check for the existence of the module at that point.

ok, 'libraries' then. I guess for this be of real benefit one would need to co-ordinate with all other module maintainters that have the same requirement so that their hook_requirements use the same key.

The second check if (!function_exists('libraries_get_path')) isn't checking for the existence of the module in the file system. It is checking to see if the function is available. During drupal installation the requirements stage precedes the installation and loading of modules that are depended upon so even if Libraries exists in the platform or site code base it won't be available to the hook. If the user is enabling this module post drupal installation the function should be available and the module need not be loaded.

StatusFileSize
new800 bytes

Hi,

I created attached patch which fixes this error message when installing the module.
This is no workaround, but an actual fix that includes the libraries.module when installing the
views_slideshow_cycle module.

Please review.

Thanks!

Thanks for the patch. How is that different from the one in #25 above?

It's worse than #25, because it just assumes that the libraries module exists, which means if it doesn't exist it will fail.

If you're adding a dependency to a module that wasn't previously a dependency you need to assume that the module doesn't exist and check for it, it also doesn't hurt to attempt to enable it if it's present but disabled, and failing that terminate the process and throw an error so the user knows that they need to get that dependency installed ASAP, even going so far as disabling the module so that the site (other than the specific functionality provided by the module) runs properly.

@Deciphered. I was hoping you would follow up on my response above.

Would you support my patch in #27 if I changed the requirements key to 'libraries'?

Based on my feedback in #28, yes, I would. I did take a quick glance just now and did see at least one coding standards issue, but that wasn't introduced by the patch it was part of the original code, so not really relevant.

I haven't had time to look further into the patch though as it's not an issue that effects me anymore, so I couldn't RTBC it for you.

This patch looks good, but I apply my project fails. Can you create a new patch?

$git apply -v views_slideshow_cycle-hook-requirements-broken-1090052-27.patch
views_slideshow_cycle-hook-requirements-broken-1090052-27.patch:9: trailing whitespace.
views_slideshow_cycle-hook-requirements-broken-1090052-27.patch:12: trailing whitespace.
views_slideshow_cycle-hook-requirements-broken-1090052-27.patch:44: trailing whitespace.
      // For example, during installation from an installation profile
Check the patch views_slideshow_cycle/views_slideshow_cycle.install...
error: views_slideshow_cycle/views_slideshow_cycle.install:?????????

Status:Needs work» Fixed

Thanks
I just manually applied #27 patch. work to me.
commit: d1d7371

Status:Fixed» Closed (fixed)

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