We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30376
    • 10 Posts
    I have a site that uses 1.0.5, but started on an older version (don't remember which), that is giving me a strange (to me) result.

    I have 3 forms on 3 different pages of the site. Each is setup to email the result to a specified email address. Usually, this works. But...it seems as though about once a month, form data is not emailed to the specified email address (I suppose the form data doesn't actually get sent anywhere) and the only thing I can do to fix it is...get this...open the chunk that contains the form code...and re-save it, without making any changes. Then it seems as though it's back to working for a while (about a month or so) until it stops working again.

    My first thought was that the webhost has some sort of cron script that runs monthly that does something to the permissions of a file, thus wreaking havoc. I suppose it's possible, but kind of difficult to test given the large interval in-between hiccups.

    Another thought is that there's something funky going on in the mySQL database and something's getting mixed up/corrupted about once a month.

    Currently, the forms are NOT working correctly, and I thought I'd post before doing my usual fix, in case there is something that I can do while they're broken to do some more long-term troubleshooting. I'd rather not post the link to the site here, but would be happy to provide a link if you PM me. Thanks for any ideas you have!
      • 3749
      • 24,544 Posts
      Next time, try just clearing the cache and see if that works. When you save the chunk, it clears the cache, which may be what is solving your problem.

      It may be that the cache file for that chunk is getting corrupted somehow, it's unlikely that it's a permission issue (since the chunk code is in the DB) but possibly permissions or ownership of the cache directory could be the problem -- you could check them the next time it happens before you do the fix.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Bob, this is Evo. No separate cache file for chunks.

        If the database were corrupted, it wouldn't be able to load the tpl from the database into the Manager's form field. It could be a problem with the site cache file; all chunks and snippets are taken from there for use during parsing, but it's odd that only the forms should be affected. The timing also makes me wonder if it's something to do with a server configuration having to do with limits on the email being sent; but in that case why would saving the chunk cause it to begin working again?

        Here's what I would do, in any case.

        Upgrade the eForm to 1.4.4.7 (you can get it here https://forums.modx.com/thread/47493/a-new-version-of-eform-with-built-in-smtp-beta-for-testing?page=3#dis-post-274564 or here https://github.com/yama/eform ) and use an external config file. The external config file is just a .php file, so you can define the template code (as well as all of the other eform parameters) in the file as a PHP variable:

        [!eForm? &config=`contact`!]


        The filename would be the first part of a filename such as 'contact.config.php' in the assets/snippets/eform/configs directory.

        $tpl = '
        <span style="color:red">[+validationmessage+]</span>
        <form id="ContactForm" method="post" action="[~[*id*]~]" enctype="multipart/form-data">
        <fieldset id="info">
        <input type="hidden" name="formid"  value="ContactForm" />
        <label for="cfName">Name: </label>
        <input tabindex="1" name="name" id="cfName" class="text" type="text" eform="Your Name::1:" />
        <input tabindex="50" type="text" name="Last__Name" id="LastName" size=30 autocomplete="off" eform="LastName::0" />
        <label for="cfEmail">Email: </label>
        <input tabindex="2" name="email" id="cfEmail" class="text" type="text" eform="Email Address:email:1" />
        <label for="cfUrl">Website: </label>
        <input tabindex="2" name="url" id="cfUrl" class="text" type="text" eform="Website::0" />
        </fieldset>
        <fieldset id="message">
        <label for="cfMessage">Message: </label>
        <textarea tabindex="3" name="message" id="cfMessage" rows="4" cols="20" eform="Message::1"></textarea>
        <input tabindex="4" type="submit" name="contact" id="cfContact" class="button" value="Send Message" />
        </fieldset>
        </form>
        ';

        The zip file contains an example config file in the configs directory.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org