Evil "eval()" dead?

eval() is still used for templates currently. The template syntax is very rich, so it compiles down to native PHP code as you might expect and these are loaded from the DB on demand. There is code in our template class to read them from the file system, though this functionality hasn't been completed yet; at the least, it's been considered since the beginning as this would allow byte code caching (APC).

Plugins (well, "code event listeners") don't use eval. You specify a class+method and that is (auto)loaded and your code is run. The listener is given a specific set of arguments, similar to MediaWiki. This actually makes it documentable, and allows more backwards compatibility or at least documentation of potential issues.

Eval() not withstanding, I'm not sure how HipHop would handle the code. We haven't run it through the static analyzer yet, though it's on the cards. I'm not sure how it would handle including template files, and you would certainly have to recompile if you edited a template.
The Pluginsystem also uses eval for faking the classes^^


PHP:
        if ($fakeNeeded)
        {
            if (!$extend)
            {
                return false;
            }

            eval('class ' . $class . ' extends ' . $fakeBase . ' {}');
        }
 
Has there been any work or progress on this? I briefly tried to compile the site in Hiphop but it didn't work for me. Recompiling is not a problem for me for template changes as its a trade off I'd be prepared to make for the scalability benefits for our forums Hiphop would be a massive boost from VB. Also any work on templates being produced as files so they don't need an eval and is there anyway to avoid the eval above in the plug in system?

Thanks.
 
Top Bottom