[Bug 619] New: Trick with storing (for later use) and overwriting native helma functions doesn't work

View: New views
4 Messages — Rating Filter:   Alert me  

[Bug 619] New: Trick with storing (for later use) and overwriting native helma functions doesn't work

by Bugzilla from bugzilla-daemon@helma.at :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

http://helma.org/bugs/show_bug.cgi?id=619

           Summary: Trick with storing (for later use) and overwriting
                    native helma functions doesn't work
           Product: Helma
           Version: 1.6.2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: JavaScript Interpreter
        AssignedTo: helma-dev@...
        ReportedBy: philipp.moser@...


the following was possible:
{{{
// storing the original function
if (!this["__stripTags__"]) this["__stripTags__"] = this["stripTags"];
// define new one
function stripTags(obj) {
   app.data.count += 1;
   res.debug(app.data.count);
   // call original function
   __stripTags__(obj);
}
}}}

but now the "stored" function is overwritten with the new function and is
called recursively until a java.lang.StackOverflowError

Maybe this is a feature?


--
Configure bugmail: http://helma.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
_______________________________________________
Helma-dev mailing list
Helma-dev@...
http://helma.org/mailman/listinfo/helma-dev

[Bug 619] Trick with storing (for later use) and overwriting native helma functions doesn't work

by Bugzilla from bugzilla-daemon@helma.at :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

http://helma.org/bugs/show_bug.cgi?id=619





------- Comment #1 from philipp.moser@...  2008-04-22 15:24 -------
Created an attachment (id=92)
 --> (http://helma.org/bugs/attachment.cgi?id=92&action=view)
small demo app


--
Configure bugmail: http://helma.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
_______________________________________________
Helma-dev mailing list
Helma-dev@...
http://helma.org/mailman/listinfo/helma-dev

[Bug 619] Trick with storing (for later use) and overwriting native helma functions doesn't work

by Bugzilla from bugzilla-daemon@helma.at :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

http://helma.org/bugs/show_bug.cgi?id=619


hannes@... changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX




------- Comment #2 from hannes@...  2008-04-22 15:41 -------
Here's the explanation for this behaviour, as well as a workaround, copied from
<http://grazia.helma.at/pipermail/helma-dev/2008-April/004142.html>:

What's happening is that __stripTags__ and stripTags are indeed the
same (scripted) functions. The reason is that Rhino, when evaluating a
script file on a scope, actually tries to define the function
properties __before__ evaluating the script, so scriptTags already
contains the scripted function when you check/set __scriptTags__.

I first wondered what code change might have triggered this behaviour,
because I didn't make that many changed between 1.6.1 and 1.6.2 in the
scripting layer. Turns out that it was that global native functions
aren't defined as READONLY anymore in 1.6.2. That used to help fend
off that first round of defining the functions before evaluation.

http://dev.helma.org/trac/helma/changeset/8795

There's an easy workaround. Just do not define your scripted function
using the name it's going to use. For example, you might just want to
define it inline:

if (!this["__stripTags__"]) {
    this['__stripTags__'] = this['stripTags'];
    this['stripTags'] = function(obj) {
        ...
    };
}

Marking as wontfix, hope this is ok with you.


--
Configure bugmail: http://helma.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
_______________________________________________
Helma-dev mailing list
Helma-dev@...
http://helma.org/mailman/listinfo/helma-dev

[Bug 619] Trick with storing (for later use) and overwriting native helma functions doesn't work

by Bugzilla from bugzilla-daemon@helma.at :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

http://helma.org/bugs/show_bug.cgi?id=619





------- Comment #3 from philipp.moser@...  2008-04-22 15:45 -------
Created an attachment (id=93)
 --> (http://helma.org/bugs/attachment.cgi?id=93&action=view)
working demo with new trick


--
Configure bugmail: http://helma.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
_______________________________________________
Helma-dev mailing list
Helma-dev@...
http://helma.org/mailman/listinfo/helma-dev
LightInTheBox - Buy quality products at wholesale price