Underscore library is not loaded.
Libraries module : 7.x-2.2
Underscore.js module 7x.2.1

When loading the libraries, edit module is waiting for a item "variant order" in order to load the library.
But...
In the function libraries_info in libraries.module
each libraries_info hook is called each after another... in my cas the order is : backbone, edit, underscore.
edit_libraries_info provide the " variant order" array, but it is overriden by the following call of underscore_edit_info which does not provide the variant_order array.

I have solved the problem by modifying the libraries_info function in libraries.module that way ;

function &libraries_info($name = NULL) {
// This static cache is re-used by libraries_detect() to save memory.
$libraries = &drupal_static(__FUNCTION__);

if (!isset($libraries)) {
$libraries = array();

// Gather information from hook_libraries_info() in enabled modules.
foreach (module_implements('libraries_info') as $module) {
foreach (module_invoke($module, 'libraries_info') as $machine_name => $properties) {
$properties['info type'] = 'module';
$properties['module'] = $module;

// adding a test here so the $libraries['underscore'] provided by edit.module is not overriden by the one provided by the underscore.js module...

if (!isset($libraries[$machine_name])) {
$libraries[$machine_name] = $properties;
}
}
}
Maybe the simple way is to remove the underscore.js module....

CommentFileSizeAuthor
#2 edit-underscore-conflict.patch588 byteststoeckler
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers’s picture

Title: underscore library not loading » Underscore library not loading: different library definitions overriding each other
Project: Edit » Libraries API
Version: 7.x-1.0 » 7.x-2.x-dev
Issue tags: +Spark

AFAICT this is an architectural problem in the Libraries API module. Moving to that project to get feedback.

tstoeckler’s picture

Project: Libraries API » Edit
Version: 7.x-2.x-dev » 7.x-1.x-dev
FileSize
588 bytes

So it is in fact currently a problem that different modules can declare the same library, but sadly there is nothing Libraries API can do.

Let me explain the situation:
- Up front: One of the (or perhaps *the*) key point(s) of Libraries API is to decouple external libraries from modules. Exactly *because* a single library can be used by multiple modules as is the case here. This is achieved in terms of placement of the library files (i.e. sites/all/libraries) but not (or not really) in terms of the metadata declaration.
- Using hook_library_info() diametrically conflicts with the above point, yet is the de-facto standard of providing library information (as it is the de-facto standard of providing information in Drupal). We have introduced the capability to deduce the information from library info files to solve this problem. Library info files are separated from modules.
- As there is no place to share and collaborate on these info files, they are practically unused, at least for contrib modules. This is something that #773508: [meta] Provide a central repository of library information (i.e. libraries.drupal.org) would solve, but that is still in pipe-dream phase, sadly.
- The approach mentioned above would not fly, as it depends on the order of modules as they are stored in the module handler. To be more specific it could just as well be that the 'underscore'-provided definition comes first in which case this would break again.
- Similar to hook_library_info() in core, Libraries API could easily introduce a namespacing by module, so that this whole problem would be avoided from the get-go. This however contradicts the entire purpose of Libraries API in the first place, as is described in the first point.

Attached patch solves this problem reliably, I think, from the edit.module side. It's untested, though.

Also note that we want to add some form of the variant order to Libraries API proper, which would make this problem vanish, as well.

tstoeckler’s picture

Status: Active » Needs review

Let's see if this passes tests.

Wim Leers’s picture

goudal: could you test the patch in #2?

Wim Leers’s picture

Project: Edit » Quick Edit
Version: 7.x-1.x-dev »
Status: Needs review » Fixed

Committed, thanks! :)

  • Commit 2e64ede on 7.x-1.x authored by tstoeckler, committed by Wim Leers:
    Issue #2201125 by tstoeckler | goudal: Fixed Underscore library not...

Status: Fixed » Closed (fixed)

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

Wim Leers’s picture

Version: » 7.x-1.x-dev

@tstoeckler: Looks like this didn't fix all of the problems: #2334769: Incompatible with underscore module. Could you please chime in there? Thanks!