Commit 9022ed7d authored by sun's avatar sun

Issue #961476 by tstoeckler: Changed libraries_get_path() to return FALSE by default.

parent 867c64ed
Libraries 7.x-2.x, xxxx-xx-xx
-----------------------------
#961476 by tstoeckler: Changed libraries_get_path() to return FALSE by default.
#958162 by tstoeckler, sun, good_man: Allow to apply callbacks to libraries.
#1125904 by tstoeckler, boombatower: Fix drush libraries-list.
#1050076 by tstoeckler: Re-utilize libraries_detect() and remove libraries_detect_library().
......
......@@ -21,7 +21,7 @@ function libraries_flush_caches() {
* Whether to prefix the resulting path with base_path().
*
* @return
* The path to the specified library.
* The path to the specified library or FALSE if the library wasn't found.
*
* @ingroup libraries
*/
......@@ -34,9 +34,7 @@ function libraries_get_path($name, $base_path = FALSE) {
$path = ($base_path ? base_path() : '');
if (!isset($libraries[$name])) {
// Most often, external libraries can be shared across multiple sites, so
// we return sites/all/libraries as the default path.
$path .= 'sites/all/libraries/' . $name;
return FALSE;
}
else {
$path .= $libraries[$name];
......@@ -323,7 +321,7 @@ function libraries_detect($name) {
if (!isset($library['library path'])) {
$library['library path'] = libraries_get_path($library['machine name']);
}
if (!file_exists($library['library path'])) {
if ($library['library path'] === FALSE || !file_exists($library['library path'])) {
$library['error'] = 'not found';
$library['error message'] = t('The %library library could not be found.', array(
'%library' => $library['name'],
......
......@@ -29,6 +29,9 @@ class LibrariesTestCase extends DrupalWebTestCase {
* @todo Better method name(s); split into detection/loading/overloading/etc.
*/
function testLibraries() {
// Test libraries_get_path().
$this->assertEqual(libraries_get_path('example'), FALSE, 'libraries_get_path() returns FALSE for a missing library.');
// Test that library information is found correctly.
$expected = array_merge(libraries_info('example_empty'), array(
'machine name' => 'example_files',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment