We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7253
    • 97 Posts
    Hello!
    It seems that whenever I’ve got a snippet that contains a PHP syntax error I get this error message when I try to display the page that contains the snippet:

    [tt]Fatal error: Out of memory (allocated 877395968) (tried to allocate 289479519 bytes) in C:\Documents and Settings\Dunc\My Documents\Web stuff\modx\logic\manager\includes\document.parser.class.inc.php on line 1287[/tt]

    For example this snippet:

    <?php
    echo 'Hello World'
    ?>


    causes this error. Add the missing semi-colon after the [tt]echo[/tt], and it works fine:

    <?php
    echo 'Hello World';
    ?>


    Should this be happening? I was expecting to get some kind of sensible PHP error back. This seems to happen for both PHP entered in the manager and [tt]included[/tt] in snippets.

    My setup is:

    Web Server:
    PHP Version 5.2.0, running as and apache module
    Apache/2.2.3 (Win32)
    MySQL Version - 5.0.27-community-nt
    OS - Windows XP Pro, SP2

    Browser/Client:
    Browser - Opera 9, Firefox 2, IE7 (tried all these, doesn’t seem to matter)
    OS - Windows XP Pro, SP2 (same machine)

    MODx:
    Version - Vanilla 0.9.5
    Any changes you’ve made - none, except creating my snippet
    Any snippets you’re running on the page that is not working properly - none, except the snippet above
    Any plugins you’re running - only the defaults.

    I’ve searched the forums and Google and read every topic containing the words ’snippet’ and ’memory’ and nothing they suggested works, or applied to my setup. I’ve checked and cleared my logs and cache for MODX, Apache and PHP. I have enough RAM and Disk space and am the only one using this server. I have one admin user logged in to the manager and the page open in another tab.
    I get two lines in my apache error.log - one pointing out the PHP error and the second, immediately after, with the out of memory error.

    I’ve posted in about this error before, here:
    http://modxcms.com/forums/index.php/topic,11955.0.html
    but as I didn’t get any replies and I’ve narrowed it down to a simple test case now, I thought I’d give it another go - so, if anyone’s got any ideas, I’d be very grateful if you could help out.

    Thanks,
    Duncan Lock
      • 22303 MODX Staff
      • 10,725 Posts
      Have you removed the TemplateSwitcher and DisableCache plugins, as described in the known issues thread for 0.9.5? Have you double-checked that your error_page is set, published, and otherwise accessible? If you’ve done all that...there is some other configuration issue that is causing the error_handler to loop, which would cause this to happen.

      Also, check and make sure you don’t have MySQL running in the new STRICT_TRANS_TABLES sql_mode (see http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html) as there are some known errors with this that might also cause this condition to appear.
        • 7253
        • 97 Posts
        No I hadn’t checked those things, being a bit of Modx noob, but I have now. wink

        I’ve read that thread and disabled the TemplateSwitcher plugin. I don’t have either the Page Hit Counter or the DisableCache plugins.
        I have double-checked that my error_page is set, published, and accessible.

        These didn’t make any difference, so I checked the MySQL sql_mode and it’s currently set to this:

        [tt]STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION[/tt]

        so I changed it to this:

        [tt]NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION[/tt]

        by setting the appripriate line in my my.ini file to:

        [tt]sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"[/tt]

        and restarting MySQL. And.... it WORKS!!!!

        now I get a proper error message:

        [tt]Parse error: parse error, unexpected $end, expecting ’,’ or ’;’ in C:\Documents and Settings\Dunc\My Documents\Web stuff\modx\logic\manager\includes\document.parser.class.inc.php(748) : eval()’d code on line 3[/tt]

        Thank-you so much!

        I have paypall’d you up, to properly express my exuberant happiness and relief. grin

        Thanks again,
        Dunc