Download & Extend

External library pathes not working due to file_exists() validations.

Project:Libraries API
Version:7.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (duplicate)

Issue Summary

@see title.

AttachmentSizeStatusTest resultOperations
libraries-external.patch691 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 135 pass(es).View details | Re-test

Comments

#1

Title:External library pathes are always marked as "not found" because of bogus file_exists() calls for them.» External library pathes not working due to file_exists() validations.

There are more places in the code where file_exists() is called on external pathes.

AttachmentSizeStatusTest resultOperations
libraries-external.patch1.18 KBIdlePASSED: [[SimpleTest]]: [MySQL] 135 pass(es).View details | Re-test

#2

Status:needs review» needs work

+++ b/libraries.module
@@ -456,7 +456,7 @@ function libraries_detect($name) {
-  if ($library['library path'] === FALSE || !file_exists($library['library path'])) {
+  if ($library['library path'] === FALSE || (!url_is_external($library['library path']) && !file_exists($library['library path']))) {

This begs the question of whether we should rename 'library path' into 'uri' ?

+++ b/libraries.module
@@ -727,8 +727,9 @@ function libraries_get_version($library, $options) {
+  $external = url_is_external($library['library path']);
+  $file = (!$external ? DRUPAL_ROOT . '/' : '') . $library['library path'] . '/' . $options['file'];
+  if (empty($options['file']) || (!$external && !file_exists($file))) {

That's veeery compact ;)

Let's use a less sparse control structure:

$file = ...;
if (!$external = url_is_external(...)) {
  $file = DRUPAL_ROOT . '/' . $file;
}

+++ b/libraries.module
@@ -727,8 +727,9 @@ function libraries_get_version($library, $options) {
   $file = fopen($file, 'r');

All of that being said, I wonder why the file_exists() does not work?

The fopen() works, but the file_exists() does not?

Sounds strange to me.

#3

Status:needs work» closed (duplicate)

Sorry for letting this sit so long before closing this down, but this is definitely duplicate of #864376: Loading of external libraries. You can see from the patches there, that I followed a similar path.

nobody click here