Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Jun 2009
    Location
    Heidelberg, Germany
    Posts
    52
    Vote Rating
    1
    kleins is on a distinguished road

      0  

    Default [TENT][3.0.0] Ext.state.StateManager#set/get and empty arrays / empty objects

    [TENT][3.0.0] Ext.state.StateManager#set/get and empty arrays / empty objects


    DESCRIPTION
    If you save an empty object using StateManager#set and CookieProvider and retrieve the same object, you get back {"" : undefined} instead of {}. The same holds for empty arrays where you get back [""] instead of [].

    TESTCASE
    The following code fails with 3.0RC2

    Code:
    // create cookies for testing
    if (Ext.state.Manager.get('empty-object') == null) {
    	Ext.state.Manager.set('empty-object', {});
    	Ext.state.Manager.set('empty-array', []);
    	location.reload();
    };
    
    var loadedObject = Ext.state.Manager.get('empty-object');
    var ok = true;
    for (key in loadedObject) {
    	ok = false;
    }
    console.log('empty object is loaded properly: ' + ok);
    
    var loadedArray = Ext.state.Manager.get('empty-array');
    loadedArray = Ext.state.Manager.get('empty-array');
    console.log('empty array is loaded properly: ' + (loadedArray.length == 0));

    SOLUTION
    In Ext.state.Provider#decodeValue check for empty values in the appropriate places. Here is my patch
    Code:
    Ext.override(Ext.state.Provider, {
        decodeValue : function(cookie){
            var re = /^(a|n|d|b|s|o)\:(.*)$/;
            var matches = re.exec(unescape(cookie));
            if(!matches || !matches[1]) return; // non state cookie
            var type = matches[1];
            var v = matches[2];
            switch(type){
                case "n":
                    return parseFloat(v);
                case "d":
                    return new Date(Date.parse(v));
                case "b":
                    return (v == "1");
                case "a":
                    var all = [];
                    if (v != "") {
                        var values = v.split("^");
                        for (var i = 0, len = values.length; i < len; i++) {
                            all.push(this.decodeValue(values[i]));
                        }
                    }
                    return all;
               case "o":
                    var all = {};
                    if (v != "") {
                        var values = v.split("^");
                        for (var i = 0, len = values.length; i < len; i++) {
                            var kv = values[i].split("=");
                            all[kv[0]] = this.decodeValue(kv[1]);
                        }
                    }
                    return all;
               default:
                    return v;
            }
        }
    })

  2. #2
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    you might want to highlight your changes in red for clarity.
    additionally, you might want to retest against RC3 instead of RC2.

  3. #3
    Sencha User
    Join Date
    Jun 2009
    Location
    Heidelberg, Germany
    Posts
    52
    Vote Rating
    1
    kleins is on a distinguished road

      0  

    Default


    Thanks.
    The changes are in red now.
    I don't have the time to test against RC3, I just took a look at the source, though, and the code for decodeValue hasn't changed, so the problem presumably still exists.

  4. #4
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    Quote Originally Posted by kleins View Post
    Thanks.
    The changes are in red now.
    I don't have the time to test against RC3, I just took a look at the source, though, and the code for decodeValue hasn't changed, so the problem presumably still exists.
    righto. i've updated the thread title to match.

  5. #5
    Sencha User
    Join Date
    Jun 2008
    Posts
    157
    Vote Rating
    0
    wiznia is on a distinguished road

      0  

    Default


    Yes, this is indeed a bug and it's on the stable version of Ext 3. Should be commited to patch next versions...

  6. #6
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,819
    Vote Rating
    608
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Fixed in SVN.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

Thread Participants: 3

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi