Jump to content
You're invited! Join our 4.6 Live Event on ZOOM 6/24 ×

Community

Debug eval'd code suggestion of solution


Recommended Posts

Debugging eval() issues (hooks, etc.) are very hard since the code is loaded in the memory, so I wrote a class that can write in the /tmp/ directory the php eval'd code so one can use xdebug on the code. Moreover, it does search for the namespace and the first class name and sets the file names based on that (for the ones that do not have a class insides the file name will be sha1($code)). I have shared this patch in hope you can implement something similar for a better debugging mechanism. It can be imported with git so you can verify it.

It would be great if the core would use a class like EvalDebug::eval($code) instead of eval($code) which is impossible to modify to write to disk (and believe me I really tried to do that). Even if the EvalDebug class does not contain anything else except eval($code) inside. Like this:

class _EvalDebug
{
    public static function eval(string $code)
    {
        return eval($code)
    }
}

This way, developers can manipulate the mechanism of eval(). Let me know what you think, thanks!

eval_disk_writer.patch

Link to comment
Share on other sites

3333.thumb.png.1c14ac345681b3e966e78739010f9004.png

in my toolbox app, in settings, there is an option for "patch init.php", what this does, will rewrite the monkeypatch method of the init class, to write hooks to a folder and use those instead of eval'ing them, so if there is an error with them, its a proper backtrace instead of a pseudo one thru eval. note: you shouldn't use this on a live site and it can't be used in the community in the cloud, so a localhost or a dev site should suffice. it does modify a core file from IPS, so if you have any unexpected behaviors, you should restore the init.php from the IPS download. 

you can grab the latest toolbox from this repo: 

https://github.com/codingjungle/toolbox

make sure you are on the dev branch when you checkout. 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

We use technologies, such as cookies, to customise content and advertising, to provide social media features and to analyse traffic to the site. We also share information about your use of our site with our trusted social media, advertising and analytics partners. See more about cookies and our Privacy Policy