Quote from: shamblett at Mar 19, 2010, 06:56 PM
Ok, but the eval() will execute the snippet code will it not? Where does the include happen? I’ve not stepped through this fully admittedly, I stopped at the eval(). Thinking, what if the snippet is not cached and it has to come direct from the DB? How is it ’included’ as such?
Just to add, I also thought that snippets were not eval’d at all in revo and as you say included, so why do we even have an eval() in the code?
Quote from: sottwell at Mar 20, 2010, 10:43 AM
Since even in Revo snippets come from the database, how can they be included? Their code has to be eval()’ed.
First, thanks for bringing this up folks; I had overlooked this. Let me explain what happened historically here.
Originally when I created Revo, all snippets were simply written to cache files that were included, registering a function into the global namespace. This worked great, eval() was banished, and remote debugging with MODx was possible.
Then I refactored the caching system last spring after using an early alpha of Revo on a huge project that involved traffic approaching 5000 simultaneous users. At this point, I needed to be able to cache the source of Snippet (or Plugin) in configurable cache providers, like one using memcached for instance. But you can’t include source code that is cached in memcached. So eval() found it’s way back into the codebase and remote debugging was crippled once again.
Now, after reviewing the modScript::loadScript() code, I have compromised and once again gotten rid of the eval(). I’m still able to cache the actual script source in any cache provider, but now this source is now written to an include file and included once again as originally intended. I’ll have this committed into branches/2.0, along with some caching optimizations involving Elements this review also sparked, before the end of the weekend.
This means you will be able to remote debug MODx snippets and plugins once again, as well as quickly test code by editing the .include.cache.php files that will now be generated on first execution of a Snippet or Plugin after the cache is cleared.