According to the hook_libraries_info() documentation:

<?php
/*
*   - path: (optional) A relative path from the directory of the library to the
*     actual library. Only required if the extracted download package contains
*     the actual library files in a sub-directory.
*/
?>

Unfortunately, libraries_get_version() doesn't take this into account. This means that if you need to pull the version from the actual library file, you can't unless it's in the top level of the library path.

The attached patch updates libraries_get_version() to use the $library['path'] variable if set.

Files: 
CommentFileSizeAuthor
#5 1953260-4-libraries-get-version-docs.patch907 byteststoeckler
PASSED: [[SimpleTest]]: [MySQL] 152 pass(es).
[ View ]

Comments

I can confirm this patch fixes the issue. Updated patch attach: Same patch, just corrected filename.

Well, this currently works as designed. Many libraries provide a separate CHANGELOG.txt or README.txt which contains the version, but is not inside of the $library['path']. While not 100% beatiful in your use-case, it wouldn't be a problem to simply duplicate the $library['path'] part in $options['file'], would it?

This bug also bite me. But also I understand your logic. "it's not a bug, it's a feature" :D

So instead of fixing the code, at least we could make the documentation more clear. Currently it says:

"file: The filename to parse for the version, relative to the library path. For example: 'docs/changelog.txt'

Maybe we could add that 'path' is not taken into account?

Title:libraries_get_version() doesn't take $libraries['path'] into accountImprove documentation of libraries_get_version() 'path' option.
Issue summary:View changes

Here is a patch to improve the documentation.

StatusFileSize
new907 bytes
PASSED: [[SimpleTest]]: [MySQL] 152 pass(es).
[ View ]

Oops, wrong patch. Here we go.

Status:Fixed» Closed (fixed)

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