phpBB

Development Discussion Board

phpBB's testing ground of bleeding edge code
Advanced search

[RFC|Merged] Get rid of eval in javascript

These requests for comments 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.

[RFC|Merged] Get rid of eval in javascript

Postby brunoais » Sun Jan 29, 2012 12:46 pm

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.*
brunoais
Registered User
 
Posts: 626
Joined: Fri Dec 18, 2009 3:55 pm

Re: [RFC] Get rid of eval in javascript

Postby callumacrae » Sun Jan 29, 2012 5:30 pm

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
});
"In JavaScript, there is a beautiful, elegant, highly expressive language that is buried under a steaming pile of good intentions and blunders"
—Douglas Crockford

View my MOD, phpBB Mobile
User avatar
callumacrae
Website Team
Website Team
 
Posts: 883
Joined: Tue Apr 27, 2010 9:37 am
Location: England

Re: [RFC] Get rid of eval in javascript

Postby brunoais » Sun Jan 29, 2012 10:18 pm

Hum... I can't find the ticket. How is it called?
brunoais
Registered User
 
Posts: 626
Joined: Fri Dec 18, 2009 3:55 pm

Re: [RFC] Get rid of eval in javascript

Postby callumacrae » Mon Jan 30, 2012 4:59 pm

Not sure, I can't find it.
"In JavaScript, there is a beautiful, elegant, highly expressive language that is buried under a steaming pile of good intentions and blunders"
—Douglas Crockford

View my MOD, phpBB Mobile
User avatar
callumacrae
Website Team
Website Team
 
Posts: 883
Joined: Tue Apr 27, 2010 9:37 am
Location: England

Re: [RFC] Get rid of eval in javascript

Postby naderman » Fri Jul 20, 2012 9:23 pm

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.
www.naderman.de
Move your forum to Forumatic - we'll take care of maintenance & spam
User avatar
naderman
Development Team Leader
Development Team Leader
 
Posts: 1649
Joined: Sun Jan 11, 2004 2:11 am
Location: Karlsruhe, Germany

Re: [RFC] Get rid of eval in javascript

Postby igorw » Fri Jul 20, 2012 10:15 pm

Done: PR #904.
User avatar
igorw
Registered User
 
Posts: 500
Joined: Thu Jan 04, 2007 11:47 pm


Return to [3.1/Ascraeus] Merged RFCs

Who is online

Users browsing this forum: No registered users and 7 guests