diff --git a/feeds.module b/feeds.module index da46661c67382462f52da95118f662c33ade862c..9711881b05554ce95f5782e99fd3ab6f79d549c9 100644 --- a/feeds.module +++ b/feeds.module @@ -1094,9 +1094,9 @@ function feeds_plugin($plugin, $id) { /** * Includes a library file. * - * @param $file + * @param string $file * The filename to load from. - * @param $library + * @param string $library * The name of the library. If libraries module is installed, * feeds_include_library() will look for libraries with this name managed by * libraries module. @@ -1104,55 +1104,64 @@ function feeds_plugin($plugin, $id) { function feeds_include_library($file, $library) { static $included = array(); - if (!isset($included[$file])) { - $included[$file] = FALSE; + $key = $library . '/' . $file; + + if (!isset($included[$key])) { + $included[$key] = FALSE; $library_dir = variable_get('feeds_library_dir', FALSE); $feeds_library_path = DRUPAL_ROOT . '/' . drupal_get_path('module', 'feeds') . "/libraries/$file"; // Try first whether libraries module is present and load the file from // there. If this fails, require the library from the local path. - if (module_exists('libraries') && file_exists(libraries_get_path($library) . "/$file")) { - require libraries_get_path($library) . "/$file"; - $included[$file] = TRUE; + if (module_exists('libraries') && $path = libraries_get_path($library) && is_file("$path/$file")) { + require "$path/$file"; + $included[$key] = TRUE; + } + elseif (is_file(DRUPAL_ROOT . '/sites/all/libraries/' . $key)) { + require DRUPAL_ROOT . '/sites/all/libraries/' . $key; + $included[$key] = TRUE; } - elseif ($library_dir && file_exists("$library_dir/$library/$file")) { - require "$library_dir/$library/$file"; - $included[$file] = TRUE; + elseif ($library_dir && is_file($library_dir . '/' . $key)) { + require $library_dir . '/' . $key; + $included[$key] = TRUE; } - elseif (file_exists($feeds_library_path)) { + elseif (is_file($feeds_library_path)) { // @todo: Throws "Deprecated function: Assigning the return value of new // by reference is deprecated." require $feeds_library_path; - $included[$file] = TRUE; + $included[$key] = TRUE; } } - return $included[$file]; + return $included[$key]; } /** * Checks whether a library is present. * - * @param $file + * @param string $file * The filename to load from. - * @param $library + * @param string $library * The name of the library. If libraries module is installed, * feeds_library_exists() will look for libraries with this name managed by * libraries module. */ function feeds_library_exists($file, $library) { + if (module_exists('libraries') && $path = libraries_get_path($library) && is_file("$path/$file")) { + return TRUE; + } - if (module_exists('libraries') && file_exists(libraries_get_path($library) . "/$file")) { + elseif (is_file(DRUPAL_ROOT . "/sites/all/libraries/$library/$file")) { return TRUE; } - elseif (file_exists(DRUPAL_ROOT . '/' . drupal_get_path('module', 'feeds') . "/libraries/$file")) { + elseif (is_file(DRUPAL_ROOT . '/' . drupal_get_path('module', 'feeds') . "/libraries/$file")) { return TRUE; } elseif ($library_dir = variable_get('feeds_library_dir', FALSE)) { - if (file_exists("$library_dir/$library/$file")) { + if (is_file("$library_dir/$library/$file")) { return TRUE; } }