We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46886
    • 1,154 Posts
    Recently I have had a lot of problems with giving users new passwords, and with new users registering.

    I will be paying a friend of mine to get to the bottom of this problem, because its so important to me, but I want to gather info from all corners in order to (1) help him and save his time and my cost, and (2) provide a good solution to the community. Probably the root cause is me doing something stupid, but if I have a working solution then I will post it for others.

    Problem 1: The links received when resetting the password don't work, even within seconds of sending them. They send you to the login screen, but the new passwords provided do not work and that is with multiple attempts.

    Problem 2: New users sign up but can't confirm their email, I will get info on what is happening in these cases. I can see them signing up multiple times...

    This seems to happen regularly, like 3 out of every 15 new registrations or so. I do not believe they are bots or anything like that, the user names and emails all sort of check out as being real users.

    I have many, many errors in my log, I let them build up, stupidly. I hope they may be helpful to find some fixes.

    The log file is huge, but just focusing on recent reports, I have two which repeat again and again, with many in a row before changing to the other one, they are:

    [2014-10-07 18:42:11] (ERROR @ /home/rayxilaw/public_html/core/components/discuss/hooks/board/post/getlist.php : 153) PHP warning: substr() expects parameter 3 to be long, string given
    [2014-10-07 21:59:25] (ERROR @ /home/rayxilaw/public_html/core/cache/includes/elements/modsnippet/16.include.cache.php : 39) PHP warning: in_array() expects parameter 2 to be array, string given


    Here is a sample of the logfile, there are lots of repeated warnings about the above, and then sometimes a small bit of some other issue, hope this isn't throwing too much at people:

    [2014-09-28 04:08:49] (ERROR @ /home/rayxilaw/public_html/core/components/discuss/hooks/board/post/getlist.php : 153) PHP warning: substr() expects parameter 3 to be long, string given
    [2014-09-29 11:02:41] (ERROR @ /index.php) Could not get table class for class: modAccess
    [2014-09-29 11:02:41] (ERROR @ /index.php) Could not get table name for class: modAccess
    [2014-09-29 11:02:41] (ERROR @ /index.php) Error 42000 executing statement: 
    Array
    (
        [0] => 42000
        [1] => 1064
        [2] => You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS `modAccess` WHERE `modAccess`.`principal` = 196' at line 1
    )
    [2014-09-30 01:06:28] (ERROR @ /home/rayxilaw/public_html/core/cache/includes/elements/modsnippet/16.include.cache.php : 39) PHP warning: in_array() expects parameter 2 to be array, string given
    [2014-10-07 18:42:11] (ERROR @ /home/rayxilaw/public_html/core/components/discuss/hooks/board/post/getlist.php : 153) PHP warning: substr() expects parameter 3 to be long, string given
    [2014-10-07 21:59:25] (ERROR @ /home/rayxilaw/public_html/core/cache/includes/elements/modsnippet/16.include.cache.php : 39) PHP warning: in_array() expects parameter 2 to be array, string given
    [2014-10-07 22:32:01] (ERROR @ /index.php) disThread: Attempt to set NOT NULL field class_key to NULL
    [2014-10-07 22:32:49] (ERROR @ /index.php) disThread: Attempt to set NOT NULL field class_key to NULL
    [2014-10-07 22:33:38] (ERROR @ /index.php) disThread: Attempt to set NOT NULL field class_key to NULL
    [2014-10-07 22:34:21] (ERROR @ /index.php) disThread: Attempt to set NOT NULL field class_key to NULL
    [2014-10-07 22:35:15] (ERROR @ /index.php) disThread: Attempt to set NOT NULL field class_key to NULL
    [2014-10-07 22:35:49] (ERROR @ /index.php) disThread: Attempt to set NOT NULL field class_key to NULL
    [2014-10-07 23:47:53] (ERROR @ /home/rayxilaw/public_html/core/cache/includes/elements/modsnippet/16.include.cache.php : 39) PHP warning: in_array() expects parameter 2 to be array, string given
    [2014-10-07 23:47:53] (ERROR @ /home/rayxilaw/public_html/core/cache/includes/elements/modsnippet/16.include.cache.php : 39) PHP warning: in_array() expects parameter 2 to be array, string given
    


    Ok, hope I can get some feedback to direct my friend a bit, thanks in advance!
      • 46886
      • 1,154 Posts
      Oh, sorry, i wasn't clear about one issue:

      The error log that should connect with the inability to reset the password of the user is:
      [2014-10-03 22:27:43] (ERROR @ /home/rayxilaw/public_html/core/components/discuss/hooks/board/post/getlist.php : 153) PHP warning: substr() expects parameter 3 to be long, string given


      The other errors were just there for context, maybe related to the registration and email confirmation process.
        • 3749
        • 24,544 Posts
        What is the snippet with the ID 16?

        I can't think of why the Discuss getList processor would be called during a password reset.

        In any event, here's the fix for the that error:

        In the file: core\components\discuss\hooks\board\post\getlist.php (be careful, there are several other getlist.php files nearby).

        Change line 153 to:

        $threadArray['excerpt'] = substr($threadArray['excerpt'],0, (float)
        $modx->getOption('discuss.post_excerpt_length', null, 500)).'...';


          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
          • 46886
          • 1,154 Posts
          Thank you BobRay, I appreciate your help.

          Snippet 16 is a FormIt snippet, called FormItIsChecked, which is just a couple of lines:
          $output = ' ';
          if ($input == $options) {
              $output = ' checked="checked"';
          }
          $input = $modx->fromJSON($input);
          if (in_array($options,$input)) {
            $output = ' checked="checked"';
          }
          return $output;
            • 3749
            • 24,544 Posts
            That error is fixed at GitHub (it looks like it was fixed two years ago). Do you have a very old version of FormIt?

            In any event, the fix is to replace that code with this:


            $output = ' ';
            if ($input == $options) {
                $output = ' checked="checked"';
            }
            $input = $modx->fromJSON($input);
            if (!empty($input) && is_array($input) && in_array($options,$input)) {
                $output = ' checked="checked"';
            }
            return $output;

            [ed. note: BobRay last edited this post 11 years, 11 months ago.]
              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
              • 46886
              • 1,154 Posts
              Huh, that's weird. I shouldn't have an old version at all, heck this modx install shouldn't be older than about 10 months or so.
                • 3749
                • 24,544 Posts
                It's possible that the version at GitHub hasn't been released, or hadn't been released at the time you installed MODX. You probably know this, but available upgrades for Extras are shown in the Package Manager grid.
                  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
                  • 46886
                  • 1,154 Posts
                  Ah good point, thanks for the reminder. Login did have an update for me, but will change that file by hand anyway.