[RFC|Merged] Get rid of eval in javascript

These requests for comments/change have lead to an implemented feature that has been successfully merged into the 3.1/Ascraeus branch. Everything listed in this forum will be available in phpBB 3.1.
Post Reply
User avatar
brunoais
Registered User
Posts: 964
Joined: Fri Dec 18, 2009 3:55 pm

[RFC|Merged] Get rid of eval in javascript

Post by brunoais »

Ticket: http://tracker.phpbb.com/browse/PHPBB3-11008
Patch: https://github.com/phpbb/phpbb3/pull/904

Intorduction
One of the things that we are getting rid of is the function eval() in the phpBB php core. But I still can't find if you are planning to get rid of eval in js too.
My proposal is to remove all eval in javascript.

The problems that stands out
The first this that stands out is the

Code: Select all

eval(onload_functions[i]);
and the 2nd thing that stands out is

Code: Select all

eval(onunload_functions[i]);
. Both are two very negative things to have in a forum like this one.
I'll also leave the third that stands out.

Code: Select all

eval('parent = document.' + id);
.

What to do, then?
My proposal is to get rid of all these needless eval() (all eval that I found don't even need to be there).
The easiest to show what I mean is use:

Code: Select all

parent = document[id];
instead of:

Code: Select all

eval('parent = document.' + id);
.
The

Code: Select all

eval(onload_functions[i]);
can easily be changed to execute anonymous functions in the array, etc, etc...

-> If this is accepted I can do that job myself.

Proposed to appear in phpbb 3.1 or in a next phpbb 3.0.*

User avatar
callumacrae
Former Team Member
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [RFC] Get rid of eval in javascript

Post by callumacrae »

There's a ticket somewhere for this. The entire piece of code will be binned with the introduction of jQuery, as jQuery handles executing stuff on load:

Code: Select all

$(function () {
    // Do stuff
});
Made by developers, for developers!
My blog

User avatar
brunoais
Registered User
Posts: 964
Joined: Fri Dec 18, 2009 3:55 pm

Re: [RFC] Get rid of eval in javascript

Post by brunoais »

Hum... I can't find the ticket. How is it called?

User avatar
callumacrae
Former Team Member
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [RFC] Get rid of eval in javascript

Post by callumacrae »

Not sure, I can't find it.
Made by developers, for developers!
My blog

User avatar
naderman
Consultant
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Berlin, Germany
Contact:

Re: [RFC] Get rid of eval in javascript

Post by naderman »

eval is still being used in a number of places, but this really should be made a ticket on the tracker. Please create one and link to it from here.

igorw
Registered User
Posts: 500
Joined: Thu Jan 04, 2007 11:47 pm

Re: [RFC] Get rid of eval in javascript

Post by igorw »

Done: PR #904.

Post Reply