ZF-9124: JQuery auto-enables if ZendX_Application_Resource_Jquery is used

Issue Type: Bug Created: 2010-02-09T07:56:18.000+0000 Last Updated: 2010-07-16T05:14:26.000+0000 Status: Resolved Fix version(s): - 1.10.7 (28/Jul/10)

Reporter: Aleksey V. Zapparov (ixti) Assignee: Dolf Schimmel (Freeaqingme) (freak) Tags: - Zend_Application_Resource

  • ZendX_JQuery

Related issues: - ZF-9980

Attachments: - Jquery.php.diff


When you add JQuery support via resources, e.g. in config.ini:

<pre class="highlight">
resources.jquery.stylesheet = "/styles/blitzer/jquery-ui.css"

It becomes always enabled. The problem is located inside ZendX_Application_Resource_Jquery::_parseOptions() method. Options are pared inside foreach loop:

<pre class="highlight">
109         foreach ($options as $key => $value) {
...         ...
156         }

But somebody put code for uienable parameter outside that loop:

<pre class="highlight">
158         if ((isset($key['uienable']) && (bool) $key['uienable'])
159             || (isset($key['ui_enable']) && (bool) $key['ui_enable'])
160             || (!isset($key['ui_enable']) && !isset($key['uienable'])))
161         {
162             $this->_view->JQuery()->uiEnable();
163         } else {
164             $this->_view->JQuery()->uiDisable();
165         }

There are two ways of solving this: First is to put code back into foreach loop, so the case will look like:

<pre class="highlight">
case 'uienable':
case 'ui_enable':
    if ((bool) $value) {
    } else {

I also propose to include new option:

<pre class="highlight">
case 'enable':
    if ((bool) $value) {
    } else {

But to keep less lines of code and to keep somebody's idea to move logic of uienable option parsing out from that loop, I have prepared a patch which I will attach to this report.


Posted by Aleksey V. Zapparov (ixti) on 2010-02-09T07:58:18.000+0000

My proposed patch

Posted by Andreas Möller (localheinz) on 2010-02-11T10:50:47.000+0000

I believe this is just an error, as in ZendX_Application_Resource_Jquery it says

<pre class="literal"> 

 *   resources.Jquery.uienable = true;
 *   resources.Jquery.ui_enable = true;

Should be fixed, though,because there's no way to disable JQuery UI unless you put the "uienable" option last in the specified options, and even then, it will only work when you have specified a "cdn_ssl" option, as otherwise, the "cdn_ssl" option is appended to the specified options and will be the last value in the iteration.

Posted by Aleksey V. Zapparov (ixti) on 2010-02-13T11:32:32.000+0000

Yes, it's an error. And that was what I said. Bug == error. Or what did you tried to say?

Posted by Dolf Schimmel (Freeaqingme) (freak) on 2010-02-13T11:41:08.000+0000

Benjamin, I think this is an issue with zendx_jquery, cause imho it shouldn't enable the ui part unless uiEnable() got called. If you disagree, please elaborate and reassign to me.

{quote}But to keep less lines of code and to keep somebody's idea to move logic of uienable option parsing out from that loop,{quote}

That 'somebody' would be me. So if you have any questions about that, feel free to ask.

Posted by Aleksey V. Zapparov (ixti) on 2010-02-14T04:52:47.000+0000


I don't have any questions.

I found a bug, fixed it (at least in my project) and shared patch with you. If you'll look into the code (at least at the part that I showed) you'll see that this code is totally unpredictable. Using variables from the loop outside it - is not good idea at all.

This is not an issue with ZendX_JQuery, it's an issue with ZendX_Application_Resource_Jquery. ZendX_Jquery doesn't enabled by default, but it get's if you'll use ZendX_Application_Resource_Jquery, as the last auto-enables jQuery UI because of small bug (or one may call it a "feature"). And enabling of jQuery UI in it's turn enables jQuery.

So, NO! This is not an issue with ZendX_JQuery.

PS In fact, you can resolve this issue with "not a bug" and pretend that it should be as it is. All I wanted is to point out the bug someone can mess with (as I did) and share a solution. Will you fix it or not - I don't care. :))

Posted by Igor Bekrenyov (tigerman) on 2010-07-06T21:45:14.000+0000

Version 1.10.6 Still the same problem. :( Apply the patch.

Posted by Christian Gräfe (cgraefe) on 2010-07-16T02:57:17.000+0000

This is definitely an issue with ZendX_Application_Resource_Jquery. Without even considering any jQuery plugin semantics: $key['uienable'] is currently used in a scope that $key is not even defined in. At least it wouldn't be if we were using a "real" programming language. ;-)

So please, fix this issue in the next release.

Posted by Dolf Schimmel (Freeaqingme) (freak) on 2010-07-16T05:12:44.000+0000

This issue was fixed with ZF-9980, committed with r22499 and merged with the release branch in r22500. Unfortunately 1.10.6 was packaged around r 22482, so it just missed it. You can either use trunk, apply the patch yourself, or wait for August. Usually in the first week of each month a new mini release is released.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.