We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 52379
    • 5 Posts
    Hello!

    I got locked out of the manager. I'm using MODX Revolutions 2.4.2 (via Mojo Marketplace) on a shared server, which runs PHP 5.6 and Apache. The problem exists on all browsers.

    After I made the website, I left it alone for several months. About a month ago, I tried to log in to change something, but couldn't sign into any account. I have two accounts.

    I assumed that my password was wrong, and tried to use the "Forgot Your Login?" button, but it does not recognize any of my usernames.

    I logged into phpMyAdmin and looked at the database. It's using "wsa_" as the table prefix, instead of "modx_". Both of my accounts are in "wsa_users", and they both had the correct usernames.

    I tried to use the steps from Resetting a User Password Manually to reset the password for one of my accounts (I only tried on the one account, just in case I messed it up). When I ran the SQL, the query was successful (I could see it), but the new password would not work in the login.

    I moved on to the PHP snippet that uses the API to reset. When I ran it, I got the reply "ERROR: No user with username $username" (with the "$username" being the username I was giving, and which was also in the database). Since I'm a foolish brave man and know a little PHP, I modified the code to be this:

    $modx= new modX();
    $modx->initialize('mgr');
    echo('<html><pre>');
    $query = $modx->newQuery('modUser');
    $query->where( array('id'=> 1) );
    $user = $modx->getObjectGraph('modUser', '{ "Profile":{}, "UserGroupMembers":{} }', $query);
    print_r($user );
    die('Done</pre></html>');
    


    As you probably expect, it only printed out just the "Done" from the "die()".

    I checked the "core/config/config.inc.php" file, and it's pointing at the correct database. I ran "print_r" on the "$query" and it was even looking at the right table, "wsa_users". And the "manager/core.config.php" file is pointing correctly at the core directory. Furthermore, the website runs perfectly fine. It's just the manager that I can't get into.

    What is the problem, and how should I fix it?

    This question has been answered by BobRay. See the first response.

      • 3749
      • 24,544 Posts
      Make sure there is a user whose ID is 1. Before you do anything, manually delete all files in the core/cache directory.

      You need to include the MODX class file and before instantiating MODX (maybe you did that) and load the error handler. I'd simplify the code that gets the user:

       /* Set path to MODX core directory */
              /* be sure this has a trailing slash */
              define('MODX_CORE_PATH', 'path/to/modx/core/');
      
          /* get the MODX class file */
          require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
       
          /* instantiate the $modx object */
          $modx = new modX();
          if ((!$modx) || (!$modx instanceof modX)) {
              die('Could not create MODX class');
          }
          /* initialize MODX and set current context */
          $modx->initialize('web');
          // or $modx->initialize('mgr');
          // in your case, it shouldn't matter
       
          /* load the error handler */
          $modx->getService('error', 'error.modError', '', '');
       
          /* Set up logging */
          $modx->setLogLevel(xPDO::LOG_LEVEL_INFO);
       
      
      $id = 1;
      if ($modx->getObject('modUser', $id)) {
        die('User is there');
      } else {
        die('User is not there');
      }


      If that fails, (and there really is a user with that ID), something is wrong with your database access. The first thing to try is repairing all tables in the DB in PhpMyAdmin.

      If that succeeds, one method is to create a new install of MODX somewhere with the desired username and password, and then cut and paste all the user fields from the database for that user into the user record at the problem site. BTW, If you goofed three times on your login, you'll be blocked, but unless you've changed things, the block will expire in an hour.

      You probably know this, but the credentials in config.inc.php are not the credentials for logging into the Manager.
        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
        • 52379
        • 5 Posts
        Thanks for replying!

        I ran that code and got 'User is not there' as the result, so I tried repairing tables, but that didn't change anything (I still got 'User is not there').

        For the record, my "wsa_users" table looks (in part) like this:

        id  username       primary_group   active
        1   (Username 1)   1               1
        2   (Username 2)   2               1


        Is that table the wrong place to look for a valid user id?

        I'm beginning to think that it's using some other database, except that the only other MODX database I have has the same users. Could it possibly be grabbing template data and all that from one database and then randomly checking some other database (maybe a nonexistent one) for the users? Or am I thinking about this all wrong?
          • 3749
          • 24,544 Posts
          That's very surreal. The database name in config.inc.php should be there twice -- make sure they're the same. While you're there, double-check the paths and URLs, especially MANAGER_PATH and MANAGER_URL.

          Another thing to try is to enable dev. tools in the browser (Ctrl-shift-i) and check the network tab as you try to log in. You can click on an entry and check the response tab. There will sometimes be a PHP error message there (embedded in a lot of ugly HTML).
            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
            • 52379
            • 5 Posts
            Surreal is a very good description (I'm glad I'm not the only one who thinks that!).

            Looking in core/config/config.inc.php, I see the correct database name stored in $dbase and $database_dsn (in the middle of some other stuff). MODX_MANAGER_PATH points correctly to /manager (I'm omitting the full path for privacy), and MODX_MANAGER_URL is "/manager/", which I believe is also correct.

            I didn't see any PHP error messages in the responses either on the test page where I was trying to use the API or on the manager login. To make sure errors would be getting through, I did "raise new Exception('exception')" on the test page. It showed up in my error log, so I looked through my error log, but found nothing else. Which is odd, because the "$modx->setLogLevel(xPDO::LOG_LEVEL_INFO);" seems like it ought to be showing up somewhere.

            As a wild guess, I just deleted my other MODX installation and its database (it was a development version of my current site), but it had no effect whatsoever. The site works just the same, and the manager fails to work. So nothing was pointing at that other site.
            • discuss.answer
              • 3749
              • 24,544 Posts
              You've probably done this, but in case your haven't, manually deleting all files in the core/cache directory is something to try, as is running setup in upgrade mode (extracted from the exact same version of MODX's .zip file). Don't proceed unless the Upgrade Existing install is checked.

              Turning off compress_js and compress_css in the system_settings table in the DB is unlikely to help, but it can't hurt, and we're grasping at straws here.

                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
                • 52379
                • 5 Posts
                I just deleted the core/cache directory, and I begin to see now why the site was working before. Everything was cached! Now the site is giving a 500.

                Also, I found the file core/cache/logs/error.log, which I guess got regenerated when I tried to go to the site. It is saying (ERROR in xPDOConnection::connect @ [path]/core/xpdo/xpdo.class.php : 3058) could not find driver. So that gives a pretty clear clue.
                  • 52379
                  • 5 Posts
                  Okay, I finally got it solved!!!

                  Apparently, my server was configured to use the wrong PHP version, so it wasn't loading the php_pdo_mysql.dll extension. So MODX couldn't come close to the database. Once that got figured out, everything (and I mean everything) started working.

                  Thank you so much for helping me through this!
                    • 3749
                    • 24,544 Posts
                    I thought of that, but it seemed unlikely since the front-end was working. Go figure. wink
                      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