We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37975
    • 12 Posts
    I get interesting issue with getCollection method and my extended modUser class.
    The problem is in class name.

    in Schema i have
    <object class="LslExtUser" table="users" extends="modUser">

    !!! the class name first letter is capital

    lslextuser.class.php file has:
    class LslExtUser extends modUser {
    	function __construct(xPDO & $xpdo){
    		parent:: __construct($xpdo);
    		$this->set('class_key','LslExtUser');
    	}
    }

    !!! class key also with first capital letter

    and now, when i call
    ... modx->getCollection('LslExtUser')

    i get in log
    (ERROR @ /index.php) Instantiated a derived class modUser that is not a subclass of the requested class LslExtUser

    and no data.
    Then, i change
    getCollection('LslExtUser')
    to
    getCollection('lslExtUser')

    and then i get a correct result with data from DB tables, but log file has next
     (WARN @ /index.php) Could not load metadata map extra/mysql/lslextuser.map.inc.php for class lslExtUser from extra.mysql.lslextuser

    All files are exists. Did clear cache in a manager, delete all data from cache folder, relogin to web context and manager context, rebuild schema.... still the same

    Actually, it`s working, but look that something wrong, if i get WARN in a log. Maybe i miss something?!

    Revo 2.2.0-pl2
      never give up!
      • 22303 MODX Staff
      • 10,725 Posts
      I assume you have your package defined and loaded via extension_packages?
        • 37975
        • 12 Posts
        Yes, sure
        [{"extra":{"path":"D:/www/home/localhost/extra/core/components/extra/model/"}}]
          never give up!
          • 37975
          • 12 Posts
          I found the problem.

          As i learned before, that when I use getCollection method then I may omit newQuery call and don't pass this as a second parameter to getCollection. That was the problem of my warnings in a log. $criteria should be explicitly specified for getCollection method.

          When i did as
          $c = $modx->newQuery('LslExtUser');
          ...modx->getCollection('LslExtUser',$c);

          then warning disappeared from a log
            never give up!