Problem/Motivation

Currently the status report displays warnings depending on which jQuery verions you've selected. Ours looks like this:

We (and I'm sure there are others like us) have a system in place that automatically creates tickets when there are warnings or errors in the status report.

Steps to reproduce

Install jQuery Update 4.x, select jQuery 1.12 and navigate to the status report page.

Proposed resolution

Add a setting to hide the warning (default off), so site managers/administrators can choose to hide the message, acknowledging the warning.

Remaining tasks

Add the setting to the admin form, hide the warnings if enabled.

User interface changes

Extra field to the admin form, hiding the warnings from the status report if enabled.

API changes

N/A

Data model changes

N/A

Comments

Jelle_S created an issue. See original summary.

mcdruid’s picture

StatusFileSize
new22.41 KB

Thanks for filing this.

However, I'm not sure why you're getting those warnings; jQuery 1.12(.4) is one of the Supported versions.

Do you have something non-default set up for jQuery UI?

On a totally clean D7 install with 7.x-4.x if I configure the default theme to use jQuery 1.12 this is what I see in the status report:

 installed versions of jQuery and jQuery UI have Security Coverage.

jelle_s’s picture

I don't have anything non-default AFAIK. I'm seeing this on all my D7 sites using jquery_update (migrated from version 3 of this module). On none of these it seems to be able to detect the JQuery UI version... I'll dig into this some more

jelle_s’s picture

Ok, I think I found the issue. Since the value for jquery_update_custom_version_jqueryui in the form on /admin/config/development/jquery_update, defaults to an empty string, saving that form results in that variable being set to an empty string. So then in jquery_update_jqueryui_replace(), (called from jquery_update_library_alter()) the version gets replaced with an empty string. I'm guessing submitting that form with an empty value for jquery_update_custom_version_jqueryui (and probably some other variables as well), should delete that variable, and not set it to an empty string? We'll probably also need an update hook that deletes the variable if the current value is an empty string, to fix current installations like mine.

mcdruid’s picture

StatusFileSize
new636 bytes

Ah right, yes the empty strings in variables managed via a system_settings_form can be a pain.

I believe that's why in a few other places we're checking whether custom values are empty.

We should probably do something like that in jquery_update_custom_version_jqueryui() too.

I think I'd prefer to do that than implement a custom submit handler to delete the variables if they're submitted as empty strings.

I actually think something else might have happened in your case where the UI version is showing up as an empty string though; with the variable set to an empty string this still returns a correct value:

$ drush vget jquery_update_custom_version_jqueryui
jquery_update_custom_version_jqueryui: ''

$ drush ev "print_r(drupal_get_library('system', 'ui'));"
Array
(
    [title] => jQuery UI: Core
    [website] => http://jqueryui.com
    [version] => 1.10.2
    [js] => Array
        (
            [misc/ui/jquery.ui.core.min.js] => Array
                (
                    [group] => -100
                    [weight] => -11
                    [data] => sites/all/modules/contrib/jquery_update/replace/ui/ui/minified/jquery.ui.core.min.js
                    [version] => 1.10.2

...snip...

...and I'm not getting any warnings on the status page; jQuery Update is still showing the same results as my previous screenshot.

The total absence of tests in this module is a bit of a nightmare.

jelle_s’s picture

I actually think something else might have happened in your case where the UI version is showing up as an empty string though; with the variable set to an empty string this still returns a correct value:

Weird, for me (without the patch) it gives me the warnings in my screenshot

drush vget jquery_update_custom_version_jqueryui
jquery_update_custom_version_jqueryui: ''
drush ev "print_r(drupal_get_library('system', 'ui'));"
Array
(
    [title] => jQuery UI: Core
    [website] => http://jqueryui.com
    [version] => 
    [js] => Array
        (
            [//ajax.googleapis.com/ajax/libs/jqueryui/jquery-ui.min.js] => Array
                (
                    [data] => //ajax.googleapis.com/ajax/libs/jqueryui/jquery-ui.min.js
                    [type] => external
                    [group] => -100
                    [weight] => -11
                    [version] => 
                )
     [...]
)
$ php -v
PHP 7.4.30 (cli) (built: Jun 27 2022 08:11:59) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.30, Copyright (c), by Zend Technologies
mcdruid’s picture

@Jelle_S if you delete that variable (and clear cache) does that change anything?

jelle_s’s picture

Yes, it does:

$ drush vdel jquery_update_custom_version_jqueryui
Enter a number to choose which variable to delete.
 [0]  :  Cancel                                
 [1]  :  jquery_update_custom_version_jqueryui
1
jquery_update_custom_version_jqueryui was deleted.                                                                                                                                                      [success]

$ drush cc all
'all' cache was cleared.                                                                                                                                                                                [success]

$ drush ev "print_r(drupal_get_library('system', 'ui'));"
Array
(
    [title] => jQuery UI: Core
    [website] => http://jqueryui.com
    [version] => 1.10.2
    [js] => Array
        (
            [//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2jquery-ui.min.js] => Array
                (
                    [data] => //ajax.googleapis.com/ajax/libs/jqueryui/1.10.2jquery-ui.min.js
                    [type] => external
                    [group] => -100
                    [weight] => -11
                    [version] => 1.10.2
                )
        [...]
)

It consequently also fixes the status report (as expected)

  • mcdruid committed f0d9861 on 7.x-4.x
    Issue #3300420 by mcdruid, Jelle_S: Handle variables set to empty...

  • mcdruid committed b7c6306 on 7.x-4.x
    Issue #3300420 by mcdruid, Jelle_S: Validate and Submit handlers for...
mcdruid’s picture

Okay, added validate and submit handlers for the settings form.

It'd be nice if the validate handler looked at the custom path when no version has been submitted and suggested a value (should be fairly easy with a regex), but I've not implemented that initially.

So now custom paths / versions that are empty will result in the variable being deleted.

Does this fix your issue @Jelle_S?

mcdruid’s picture

Status: Active » Fixed

This functionality has changed a bit as we've removed all of the "unsupported" library versions.

The module now checks custom versions against the latest available releases and shows that info in the Status report... however this functionality can be disabled.

Thanks for the report; I think we can close this issue.

Status: Fixed » Closed (fixed)

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