The admin config page should report the name of the file in use as well as the directories that are scanned for possible candidates.
This will hopefully make it easier to understand issues with missing tests due to the inclusion of a wrong file.
Original report
In my configuration > development > Modernizr > rebuild Modernizr page I get a message saying that the load test is missing from my Modernizr build. I also have a strange entry at the end of my tests list labeled: "load: No description available."
I've cleared my site's cache, downloaded a new modernizr build and even removed the module and installed it again without any luck. This issue only appeared when I updated from 3.2 to 3.3. I can duplicate the issue on all of my testing servers but when I try to duplicate it on a fresh Drupal install everything works just fine. Any idea what might be going on here?
Comment | File | Size | Author |
---|---|---|---|
#28 | 2349193-modernizr-loaded-file-in-admin-page-28.patch | 2.45 KB | berliner |
| |||
#12 | modernizr.custom.16849.txt | 13.26 KB | Kebz |
Comments
Comment #1
pedrospIt seems that the yepnope.js component is deprecated: https://github.com/SlexAxton/yepnope.js#deprecation-notice
Still struggling how to deal with that , though...
Comment #2
johns996 CreditAttribution: johns996 commentedSo the original load, which is yepnope, is the thing the module is checking for? And the second "load" that is listed on my screen is the new version of Modernizr's load? Is there even a new version of load? I know when I'm creating the build to download I'm definitely checking the "load" option to include that functionality.
Comment #3
The Mad Martian CreditAttribution: The Mad Martian commentedthis is due to how modernizr module gets what tests are available from the js library.
opening up modernizr.js I can see that each test is separated with a hyphen ( or minus).
The very last test in this list is load and ends without a hyphen.
adding a hyphen to the end of the test list within Modernizr.js makes Modernizr module report load is present and available.
I don't know much about the inner workings of the module but the function which looks through the test list has to have a rule applied to not expect a hyphen at the very end of the list
/*edit*/
I will provide examples of changes
Root directory
>
*/sites/*/libraries/modernizr/modernizr
Before fix
After fix
but a fix should be made to the part of the modernizr module which parses this list to not expect the hyphen on the end
Comment #4
ruplHi @johns996, could you please follow the issue submission guidelines and paste the URL of your Modernizr JS library? It's similar to the URL provided by Mad Martian in comment 3. I can't debug your support request without this URL. All issues of this nature are support requests until I can reproduce the problem, so I have re-classified this issue temporarily.
Regarding the deprecation of yepnope, this does not yet affect new Modernizr builds. http://modernizr.com still produces Modernizr 2.8.3 - which includes the same version of yepnope (aka Modernizr.load) as we have been using since early 2012. When modernizr.com updates to 3.0 then we will have an issue with yepnope. I'm honestly not quite sure what to do about that yet but please move all thoughts regarding that topic to here: #2311603: Address policy on upstream support
Comment #5
johns996 CreditAttribution: johns996 commentedHere's the link to my library:
http://www.nmu.edu/sites/all/libraries/modernizr/modernizr.min.js
Comment #6
ruplJust for posterity, here is the link in the library (in case it is updated in the future)
Comment #7
ruplOk I took the library you linked to and put it in my standard dev environment for the module. On a vanilla Drupal 7.31 install I see the following when I drop your library into sites/all/libraries/modernizr. It seems to work perfectly.
Comment #8
ruplAlso you can search the file you linked to for "yepnope" and it's definitely there, with 6 results appearing near the end of the file.
Question: are you having a problem with yepnope or are you just noticing the strange error on the Drupal admin UI?
Comment #9
johns996 CreditAttribution: johns996 commentedYepnope seems to work just fine. The only issue I've noticed is the error in the Drupal admin. It's fixable by adding a "-" after load in the second line, just as Mad Martian said. I pulled that out again so you can see the file as it was generated.
Edit: I created a fresh install of drupal and loaded the modernizr module and then put this modernizr build in it. I saw the same thing you did, meaning that everything seemed to work just fine and no errors in the drupal admin. However on all three of my other instances of drupal (production and two testing environments) I get the load missing error. My production/testing involves a large multisite (169 sites) with a collection of other modules running. I didn't go through each one to see if it was a module causing the issue or something with the multisite because the fix Mad Martian posed worked.
Comment #10
droppinshucks CreditAttribution: droppinshucks commentedI get the same error after updating from 3.2 to 3.3. The Mad Martian hyphen fix also works for me. I've only tested this on one site.
Comment #11
ruplok. Thank you for confirming the bug.
Editing the Modernizr file is not a maintainable option, we definitely need to find the problem within the module. We probably just need to adjust the code that looks at the build URL. I'll take a look at this soon.
Comment #12
Kebz CreditAttribution: Kebz commentedI'm still getting this message inside my status report even though I've downloaded several versions each time.
Modernizr Tests You haven't created a custom build yet.
Modernizr works best with a custom build. Visit the Modernizr settings page to create one.
Once I click on the link (xxx .com/?q=admin/config/development/modernizr)
I get this warning message:
Attached is the .js file saved as a text file so I can upload here
modernizr.custom.16849.js
When I go to build, it generates and downloads with the word "custom" in the filename.
Comment #13
ruplHi Kebz, unfortunately like the other examples in this issue, I cannot reproduce the problem on a vanilla install of Drupal 7. I see that you have
yepnope
and it is being assigned to Modernizr.load within the JS file as expected. So you are building the file properly and if the JS file is appearing in your theme then you are ok to use it as-is. Sorry for the false warning, I have never figured out what is happening to others' installs.Comment #14
Kebz CreditAttribution: Kebz commentedThanks for responding @rupl
Is there a naming convention to be used properly? Because the report says it's not built.
So when we go to the Modernizr site, it takes us to their download page with pre-selected items based on the tests listed.
>> filename: modernizr.custom.16849.js
According to these instructions (https://www.drupal.org/project/modernizr), it says to download filename "modernizr-X.Y.min.js", but my files are not getting the ".min" name inside the files I'm receiving. Am I missing a step somewhere??
Also, according to the documentation here https://www.drupal.org/node/1913748, it says this
However, I get this (as you mentioned) a "false warning" You don't seem to have a custom build of Modernizr installed yet. This page will help generate one for you. and nothing is appearing in red.
BTW, I'm a little confused here on what you wrote:
What do you mean by "if the JS file is appearing in my theme"?? How do I know if it's doing what it's suppose to do?
Thanks in advance!
Comment #15
Kebz CreditAttribution: Kebz commentedI reviewed the code inside the file "modernizr.install" -- and it specifically says that we have to rename the downloaded file to "modernizr.min.js"
HOWEVER, even after renaming it, it is still giving me the error notice =\ sigh
Comment #16
hass CreditAttribution: hass commentedI'd like to note one thing I have found in the module. Not sure if related, but let's say you run navbar and you place the navbar modernizr build in the libraries/modernizr folder with filenames navbar requires. Than modernizr complains two features are missing. Ok, download modernizr custom build and place in the sane folder.
Modernizr module finds the navbar build first and complains the correct modernizr js file is still missing, but it is inside the folder...
I think modernizr module should scan all files and check all for the features and than remember and add the one that has all features included.
Not sure if i opened a case for this bug in modernizr queue.
Comment #17
jiv_e CreditAttribution: jiv_e commentedKebz, if you have installed using drush there should be a modernizr-latest.js file in the libraries folder. Try to remove that. It worked for me.
Comment #18
Kebz CreditAttribution: Kebz commented@jiv_e .. thank you!! That did the trick =)
You know, I did see that file in there, but didn't think nothing of it cause I thought the code is looking specifically for the other files. And strangely enough, I did change the file name of that to the requested filename "modernizr.min.js" -- but it was the copy on my local drive and then I uploaded ... anyhoo... all is good now... yay.. thanks again =)
Comment #19
jiv_e CreditAttribution: jiv_e commentedIf I understand right modernizr module search only for the first file it founds in the libraries/modernizr folder. When it founds the modernizr-latest.js it doesn't bother to search the right file.
Comment #20
ruplI think that's the true nature of this bug and a quick search through issues didn't reveal anything with near as much discussion as this issue so I'm reclassifying it to deal with the bug.
Comment #21
aubjr_drupal CreditAttribution: aubjr_drupal commentedThe module also can't find a modernizr script if another script named modernizr2.8.3.js is in the same directory. I left that old modernizr2.8.3.js script in the /libraries/modernizr director as a backup during testing, and it couldn't find modernizr.js until the backup was removed from the directory. Strange behavior.
Comment #22
berliner CreditAttribution: berliner commentedI just spent more than an hour researching why modernizr would not work correctly on our production server, while locally and on all stage and testing servers it was working correctly. Turned that on prod we had a leftover "test" directory from earlier versions that contained the file `modernizr-1.7.min.js`. So I'm definitely in favour of using a custom build file if available.
In order to understand this kind of problem it would also be of great help if either the status page or the modernizr settings page would mention which file it is actually loading. I realise that this is something that can be found by disabling JS aggregation and looking at the loaded resources, but you usually don't want to do that on a busy production site just to get this kind of information.
Comment #23
ruplI'm sorry that it caused you trouble. I like the suggestion to display the file which was found. That is simpler and less philosophical than "preferring" a custom build, which isn't technically possible. You can name the file many names as long as you follow a regex. However reporting the file name is very doable and I think is good info to display anyway.
I definitely wouldn't want to be responsible for making someone disable aggregation in production! ;)
Comment #24
berliner CreditAttribution: berliner commentedGreat news. Do you need a helping hand on this?
Should this be handled here or in a new issue?
Comment #25
ruplThat would be great! Just FYI I am leaving on my honeymoon in 4 hours so I might be slow to respond for a while. But I would be happy to accept a patch.Otherwise I can get around to it in April.
If you create a patch go ahead and do it here. I've updated the issue title to indicate new direction.
Comment #26
berliner CreditAttribution: berliner commentedHappy honeymoon then!!!
I'll have the patch ready for your return ;)
Comment #27
berliner CreditAttribution: berliner commentedComment #28
berliner CreditAttribution: berliner commentedThis patch adds information about the currently loaded file if any. If no file is found, a list with the scanned directories is also displayed.
I have also removed duplicate paths if the libraries module is used.
In the long term, I would actually propose to make the file selectable if multiple candidates are found. This should be pretty straight-forward using a dropdown and a variable setting. But that should probably go into it's own issue.
Comment #30
ruplThis patch is tip top! Thanks so much. It's committed to dev with your name attached.
I have some other housecleaning to do but I will stamp a new release soon.
Comment #31
berliner CreditAttribution: berliner commentedGreat!
Comment #32
ruplNew release including this patch: https://www.drupal.org/project/modernizr/releases/7.x-3.10