Advertisement:

Author Topic: Why does SMF use eval()?  (Read 14135 times)

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Why does SMF use eval()?
« on: September 20, 2005, 04:59:35 PM »
When loading template and language files, SMF uses eval() instead of require_once()/include_once().  The specific reason for this is that, with eval(), if there is an error, PHP tells SMF.  With include_once(), it just spits out an error.

Benchmarks show that eval() isn't much slower, and it's no more a security risk because we mean to include_once() the file anyway.  However, if you have an accelerator installed, like eAccelerator, eval() is slower.  Much slower.  And it uses more memory, too.

As such, you'll want to run the following query to disable eval():

REPLACE INTO smf_settings
   (variable, value)
VALUES ('disableTemplateEval', '1');

Please note that this will also disable the "pretty" error messages that highlight the line the error occured on, too.  All you get is PHP's error message, after this.  Still, it's not a huge price to pay... since you can always change it back to 0 when you mess with your templates.

-[Unknown]

Offline joh87swe

  • Jr. Member
  • **
  • Posts: 242
Re: Why does SMF use eval()?
« Reply #1 on: April 17, 2007, 12:53:32 PM »
Can't find how to enable disableTemplateEval, I've searched in the database whithout any result.

Cordially,
Johan

Offline Thantos

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 16,139
  • Gender: Male
Re: Why does SMF use eval()?
« Reply #2 on: April 17, 2007, 01:10:03 PM »
Run the query that [Unknown] posted in your database interface.

Offline Joshua Dickerson

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,663
  • Gender: Male
    • joshuaadickerson on LinkedIn
Re: Why does SMF use eval()?
« Reply #3 on: April 18, 2007, 12:42:31 PM »
* groundup wonders if there should be an interface for this
Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?

Offline goitalone

  • Full Member
  • ***
  • Posts: 490
    • SDA-N-Friends Christian Answers Forum
Re: Why does SMF use eval()?
« Reply #4 on: May 15, 2007, 10:14:38 PM »
I am not sure where to do this. After I submit the query, it says:

 You have to choose at least one column to display.

Which column?


Offline metallica48423

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,842
  • Gender: Male
  • Professional Multislacker!
    • Zentendo
Re: Why does SMF use eval()?
« Reply #5 on: May 16, 2007, 02:23:56 AM »
you should be able to do it after selecting your database in the left pane, then clicking sql
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

Quote
Microsoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"

Useful Links:
Online Manual!
How to Help us Help you   
Search
Settings Repair Tool
     

Offline H

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 21,656
  • Gender: Male
Re: Why does SMF use eval()?
« Reply #6 on: May 16, 2007, 04:34:35 PM »
* groundup wonders if there should be an interface for this

If it isn't already it would make sense to have it auto-enabled when caching is enabled
Huw
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

Offline goitalone

  • Full Member
  • ***
  • Posts: 490
    • SDA-N-Friends Christian Answers Forum
Re: Why does SMF use eval()?
« Reply #7 on: September 03, 2007, 12:03:31 PM »
Ok, hey...way back when I never could figure out how to do this query thing..and I need to because I have like 10 billion errors in the forum error log..I need to figure how to resolve these I think.

Um...I am using MySql Administrator, can I use that to do this Query?

I am running my own home webserver and a buchna crap happened way back and it messed up my PHPMyAdmin and now I can't figure out how to fix it....it doesn't work anymore and I am pissed about the fact I spent 2 days trying to fix it and can't.

I basically don't know how to run a query period...Ima query noob!!
« Last Edit: September 03, 2007, 12:11:10 PM by goitalone »

Offline CiHaD

  • Jr. Member
  • **
  • Posts: 272
  • Gender: Male
  • kişisel yazı
    • film izle
Re: Why does SMF use eval()?
« Reply #8 on: September 04, 2007, 10:34:03 AM »
mee to ?

I am using MySql Administrator, can I use that to do this Query?

Offline goitalone

  • Full Member
  • ***
  • Posts: 490
    • SDA-N-Friends Christian Answers Forum
Re: Why does SMF use eval()?
« Reply #9 on: September 04, 2007, 10:39:33 AM »
I dunno still how to do it correctly from MySQL Admin cause it didn't work for me when I tried it, but my question has been resolved doing it a different way here:

http://www.simplemachines.org/community/index.php?topic=192818.msg1227674#msg1227674

Worked and I have fixed all my errors as well :)