We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49407
    • 159 Posts
    I'm in complete disbelief at what I'm experiencing.

    I created a test user account, logged in from my Mac Pro. Everything is fine. (This is through login extra on the front end)

    Then, I use the exact same credentials on my android, and a windows machine, resulting in the invalid username or password error. (also front end)

    The errors in the back-end log are...

    [2016-08-11 21:50:46] (ERROR @ /index.php) Could not load class: extUser from mysql.extuser.
    [2016-08-11 21:50:46] (ERROR @ /index.php) extUser::load() is not a valid static method.

    How in the heck could this be?!

    What could be causing any difference server-side based on the machine I'm using to login with?

    I've thoroughly tested this over, and over again at least 10 times ensuring that the credentials are cased correctly and everything. Each time I attempt login from anything other than my Mac Pro I get the above errors.

    I'm just at a loss.

    Edit:
    MODX Revolution 2.4.2-pl
    login-1.9.0-pl
    classextender-2.1.0-pl

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

    [ed. note: aaronkent last edited this post 10 years, 1 month ago.]
      • 49407
      • 159 Posts
      Attached a screenshot of my extension_packages...hasn't changed.

      I went through the steps to reinstall ClassExtender. The map files are there, my custom user data map is exactly the same.

      This just happened out of nowhere it seems. From what I can see, absolutely no reason why the ClassExtender went haywire.

      Flushed the cache, twice, still not allowing login, still generating the above error, only on machines that don't have successful login cookies.

      Strangely, data that is in the extended user class "UserAttributes", table "ext_user_attributes" can be accessed with xPDO.

      The only thing that seems to have crashed is the login extra?
        • 49407
        • 159 Posts
        After reinstalling ClassExtender a third time I'm now getting this error...

        No foreign key definition for parentClass: modUser using relation alias: ExtUser

        Why is class extender bugging out after many months of successful use?
          • 49407
          • 159 Posts
          Because reinstalling ClassExtender lead me on a wild goose chase, ultimately causing more, worse problems, I've rolled back my backup to produce the original errors...

          [2016-08-12 10:47:11] (ERROR @ /index.php) Could not load class: extUser from mysql.extuser.
          [2016-08-12 10:47:11] (ERROR @ /index.php) extUser::load() is not a valid static method.

          I still don't understand why this started happening after months of successful use without errors.

          UserURLs has been added since and also CustomRequest, which I can't see causing the problem with extUser at all, in any way.
            • 3749
            • 24,544 Posts
            Except for one very old version, ClassExtender does't change the class_key of the user object, so the extUser object, and it's files, no longer exist.

            If the user you're logging in as has a class_key of extUser, try changing it to modUser.

            If that's the issue, you may also have to modify any code of yours that tries to get the extUser object.

            See this for more info (especially the upgrade notes): http://bobsguides.com/classextender-class.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
              • 49407
              • 159 Posts
              Hi BobRay, thanks for the reply. After many hours of troubleshooting I discovered that the errors originated from not adding the package correctly when I updated some snippet, however, since I had to recreate the "ext_user_attributes" table there is no longer a foreign key in entry in the mySQL database. Now the error is...

              No foreign key definition for parentClass: modUser using relation alias: ExtUser


              I tried adding a foreign key entry in phpmyadmin, failing miserably at it and causing...
              [2016-08-12 12:51:32] (ERROR @ /index.php) Error 23000 executing statement:
              INSERT INTO `modx_user_attributes` (`internalKey`, `fullname`, `email`, `phone`, `mobilephone`, `blocked`, `blockeduntil`, `blockedafter`, `logincount`, `lastlogin`, `thislogin`, `failedlogincount`, `sessionid`, `dob`, `gender`, `address`, `country`, `city`, `state`, `zip`, `fax`, `photo`, `comment`, `website`, `extended`) VALUES (49, 'Bob Smith', '[email protected]', '', '', 0, 0, 0, 0, 0, 0, 0, '', 0, 0, '', '', '', '', '', '', '', '', '', '{\"alias\":\"Johny Test\",\"bio\":\"Test account\",\"key\":\"\"}')
              Array
              (
                  [0] => 23000
                  [1] => 1452
                  [2] => Cannot add or update a child row: a foreign key constraint fails (`i983192_modx1`.`modx_user_attributes`, CONSTRAINT `ExtUser` FOREIGN KEY (`internalKey`) REFERENCES `ext_user_attributes` (`id`))
              )
              
              [2016-08-12 12:51:32] (ERROR @ /index.php) Error 23000 executing statement:
              INSERT INTO `modx_user_attributes` (`internalKey`, `fullname`, `email`, `phone`, `mobilephone`, `blocked`, `blockeduntil`, `blockedafter`, `logincount`, `lastlogin`, `thislogin`, `failedlogincount`, `sessionid`, `dob`, `gender`, `address`, `country`, `city`, `state`, `zip`, `fax`, `photo`, `comment`, `website`, `extended`) VALUES (49, 'Bob Smith', '[email protected]', '', '', 0, 0, 0, 0, 0, 0, 0, '', 0, 0, '', '', '', '', '', '', '', '', '', '{\"alias\":\"Johny Test\",\"bio\":\"Test account\",\"key\":\"\"}')
              Array
              (
                  [0] => 23000
                  [1] => 1452
                  [2] => Cannot add or update a child row: a foreign key constraint fails (`i983192_modx1`.`modx_user_attributes`, CONSTRAINT `ExtUser` FOREIGN KEY (`internalKey`) REFERENCES `ext_user_attributes` (`id`))
              )
              
              [2016-08-12 12:51:32] (ERROR @ /index.php) Error 23000 executing statement:
              INSERT INTO `modx_user_attributes` (`internalKey`, `fullname`, `email`, `phone`, `mobilephone`, `blocked`, `blockeduntil`, `blockedafter`, `logincount`, `lastlogin`, `thislogin`, `failedlogincount`, `sessionid`, `dob`, `gender`, `address`, `country`, `city`, `state`, `zip`, `fax`, `photo`, `comment`, `website`, `extended`) VALUES (49, 'Bob Smith', '[email protected]', '', '', 0, 0, 0, 0, 0, 0, 0, '', 0, 0, '', '', '', '', '', '', '', '', '', '{\"alias\":\"Johny Test\",\"bio\":\"Test account\",\"key\":\"\"}')
              Array
              (
                  [0] => 23000
                  [1] => 1452
                  [2] => Cannot add or update a child row: a foreign key constraint fails (`i983192_modx1`.`modx_user_attributes`, CONSTRAINT `ExtUser` FOREIGN KEY (`internalKey`) REFERENCES `ext_user_attributes` (`id`))
              )
              
              [2016-08-12 12:51:32] (ERROR in setExtUser Snippet @ /index.php) Failed to create object of type: Profile


              I since removed the foreign key entry in phpmyadmin and am stuck as I have absolutely no idea which table to relate to ext_user_attributes or how to set it up using the ExtUser alias.
                • 49407
                • 159 Posts
                In core/components/classextender/model/schema/extendeduser.mysql.schema.xml

                <?xml version="1.0" encoding="UTF-8"?>
                <model package="extendeduser" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" tablePrefix="ext_" version="1.1">
                    <!-- inherit the modx user and extend it -->
                    <object class="extUser" extends="modUser">
                            <composite alias="ExtUser" local="id" class="UserAttributes" foreign="id" cardinality="one" owner="foreign" />
                    </object>
                    <!-- track all user attributes -->
                	<object class="UserAttributes" table="user_attributes" extends="xPDOObject">
                		<field key="id" dbtype="int" precision="11" phptype="integer" null="false" index="pk" />
                		<field key="api_key" dbtype="varchar" precision="64" phptype="string" null="false" />
                		<field key="alias" dbtype="varchar" precision="64" phptype="string" null="false" />
                		<field key="bio" dbtype="text" phptype="string" null="false" />
                		<field key="medium" dbtype="varchar" precision="255" phptype="string" null="false" default="Undisclosed" />
                		<field key="genetics" dbtype="varchar" precision="255" phptype="string" null="false" default="Undisclosed" />
                		<field key="experience" dbtype="varchar" precision="255" phptype="string" null="false" default="Undisclosed" />
                		<field key="environment" dbtype="varchar" precision="255" phptype="string" null="false" default="Undisclosed" />
                		<field key="followers" dbtype="longtext" phptype="string" null="true" />
                		<field key="following" dbtype="longtext" phptype="string" null="true" />
                		<field key="upvotes" dbtype="int" precision="11" phptype="integer" null="false" default="0" />
                		<field key="voters" dbtype="longtext" phptype="string" null="true" />
                		<field key="user_votes" dbtype="longtext" phptype="string" null="true" />
                		<field key="grow_votes" dbtype="longtext" phptype="string" null="true" />
                		<field key="chronicle_votes" dbtype="longtext" phptype="string" null="true" />
                		<field key="rating" dbtype="int" precision="11" phptype="integer" null="false" default="0" />
                
                		<index alias="id" name="id" primary="false" unique="true" type="BTREE">
                            <column key="id" length="" collation="A" null="false" />
                        </index>
                        <aggregate alias="User" class="modUser" local="id" foreign="id" cardinality="one" owner="foreign"/>
                        <aggregate alias="Profile" class="modUserProfile" local="id" foreign="internalKey" cardinality="one" owner="foreign"/>
                	</object>
                </model>


                Also in core/components/extendeduser/model/schema/extendeduser.mysql.schema.xml

                <?xml version="1.0" encoding="UTF-8"?>
                <model package="extendeduser" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" tablePrefix="ext_" version="1.1">
                    <!-- inherit the modx user and extend it -->
                    <object class="extUser" extends="modUser">
                            <composite alias="ExtUser" local="id" class="UserAttributes" foreign="id" cardinality="one" owner="foreign" />
                    </object>
                    <!-- track all user attributes -->
                	<object class="UserAttributes" table="user_attributes" extends="xPDOObject">
                		<field key="id" dbtype="int" precision="11" phptype="integer" null="false" index="pk" />
                		<field key="api_key" dbtype="varchar" precision="64" phptype="string" null="false" />
                		<field key="alias" dbtype="varchar" precision="64" phptype="string" null="false" />
                		<field key="bio" dbtype="text" phptype="string" null="false" />
                		<field key="medium" dbtype="varchar" precision="255" phptype="string" null="false" default="Undisclosed" />
                		<field key="genetics" dbtype="varchar" precision="255" phptype="string" null="false" default="Undisclosed" />
                		<field key="experience" dbtype="varchar" precision="255" phptype="string" null="false" default="Undisclosed" />
                		<field key="environment" dbtype="varchar" precision="255" phptype="string" null="false" default="Undisclosed" />
                		<field key="followers" dbtype="longtext" phptype="string" null="true" />
                		<field key="following" dbtype="longtext" phptype="string" null="true" />
                		<field key="upvotes" dbtype="int" precision="11" phptype="integer" null="false" default="0" />
                		<field key="voters" dbtype="longtext" phptype="string" null="true" />
                		<field key="user_votes" dbtype="longtext" phptype="string" null="true" />
                		<field key="grow_votes" dbtype="longtext" phptype="string" null="true" />
                		<field key="chronicle_votes" dbtype="longtext" phptype="string" null="true" />
                		<field key="rating" dbtype="int" precision="11" phptype="integer" null="false" default="0" />
                
                		<index alias="id" name="id" primary="false" unique="true" type="BTREE">
                            <column key="id" length="" collation="A" null="false" />
                        </index>
                        <aggregate alias="User" class="modUser" local="id" foreign="id" cardinality="one" owner="foreign"/>
                        <aggregate alias="Profile" class="modUserProfile" local="id" foreign="internalKey" cardinality="one" owner="foreign"/>
                	</object>
                </model>


                Cleared cache folder repeatedly. Seems to be on the mySQL side and I'm not educated enough to create a foreign key correctly, apparently. tongue
                  • 49407
                  • 159 Posts
                  I reset the class_key to modUser via phpmyadmin.

                  I tried to login front end.

                  Get 500 error on front, No foreign key definition for parentClass: modUser using relation alias: ExtUser on back.

                  Switch the class_key back to extUser in the DB via phpmyadmin.

                  Hit the retry button in chrome.

                  Logs me in just fine.

                  If I logout and clear cookies, I have to do the exact same thing to log me back in.

                  If I leave the class_key as extUser, I always get invalid user/pass message on front and...

                  [2016-08-12 20:19:26] (ERROR @ /index.php) Could not load class: extUser from mysql.extuser.
                  [2016-08-12 20:19:26] (ERROR @ /index.php) extUser::load() is not a valid static method.

                  On the back.

                  I'm frustrated beyond words.
                  • discuss.answer
                    • 3749
                    • 24,544 Posts
                    I'm sorry you're having so much trouble.

                    It looks like you may have created your own extUser class in core/components/extendeduser/. That has nothing to do with ClassExtender and may be interfering with things. Either you created the stuff in core/components/extendeduser, or you installed a package that did. That code stores the user data in the extended field of the modUserProfile object (modx_user_attributes table), which ClassExtender has never done. ClassExtender creates a separate table for the data: ext_user_data, which you reference through the userData object (assuming that you didn't change the CE defaults).

                    Also, it's very unlikely that ClassExtender would be affect the Login process, unless you have a plugin connected to one of the Login System Events. CE doesn't touch the modUser object, and the Login code doesn't refer to the userData object.

                    The foreign key definition is not in the DB, but in the class and map files based on the schema, though I don't know why a user object would have a 'parent', and I don't see it in any of your schemas.

                    BTW, MODX pays no attention to schema files. It looks only at the class and map files generated from the schema. You have to generate those files from the schema. This is what CE does when you submit the CE form.

                    If you want to use ClassExtender, you'll have to change the user class_key to modUser. You'll also have to leave the modx_users and modx_user_attributes tables in their original form. You may also have to modify any custom PHP code that you've written to access the extra fields. If you're going that route, I'd recommend renaming the core/components/extendeduser directory, since its files can only cause trouble. That will probably give you a (hopefully) clearer error message if any code tries to access those files.

                    Your other alternative would be to uninstall ClassExtender and try to make the other, ExtendedUser, package work. Obviously, I can't help you with that.

                      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
                      • 3749
                      • 24,544 Posts
                      After looking at your schemas some more, it looks like you've mixed two approaches. The ExtendedUser package extends the modUserProfile object to add the extra fields in the 'extended' field. It looks like you've tried to do that with ClassExtender. Here is the default schema for CE's user data:

                      <?xml version="1.0" encoding="UTF-8"?>
                      <model package="extendeduser" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" tablePrefix="ext_" version="1.0.0">
                          <!-- extend the modUser class -->
                          <object class="extUser" extends="modUser">
                              <composite alias="Data" local="id" class="userData" foreign="userdata_id" cardinality="one" owner="local"/>
                          </object>
                          <object class="userData" table="user_data" extends="xPDOSimpleObject">
                              <field key="userdata_id" dbtype="int" precision="11" phptype="integer" null="false" attributes="unsigned"/>
                              <field key="firstName" dbtype="varchar" precision="50" phptype="string" null="true"/>
                              <field key="lastName" dbtype="varchar" precision="50" phptype="string" null="true"/>
                              <field key="title" dbtype="varchar" precision="100" phptype="string" null="true"/>
                              <field key="company" dbtype="varchar" precision="100" phptype="string" null="true"/>
                              <field key="registrationDate" dbtype="datetime" phptype="datetime"/>
                              <field key="extra" dbtype="varchar" precision="100" phptype="string" null="true"/>
                              <field key="extra2" dbtype="varchar" precision="100" phptype="string" null="true"/>
                              
                      
                              <index alias="userdata_id" name="userdata_id" primary="false" unique="true" type="BTREE">
                                  <column key="userdata_id" length="" collation="A" null="false"/>
                              </index>
                              <aggregate alias="User" class= "modUser" local="userdata_id" foreign="id" cardinality="one" owner="foreign"/>
                          </object>
                      </model>


                      To use CE, you would normally just modify the field list to include your fields. Notice that the data would go to the ext_user_data table, not the modx_user_attributes table.
                        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