We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40045
    • 534 Posts
    The scenario is this one: I have several MIGXdb custom components/classes/tables which I would like to monitor a bit better, so I changed the default processor for updating items a bit and added

    $modx->logManagerAction('MIGX action: ' . $task, $classname, $object->get('songid'));


    this so far works very well and I can log if a user updates a MIGXdb item, buuut, my error log gets cramped with messages like:

    [2013-07-25 16:20:02] (ERROR @ /connectors/system/log.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 '=> 3973)' at line 1
    )
    
    
    [2013-07-25 16:26:43] (ERROR @ /connectors/system/log.php) TimelineSong::load() is not a valid static method.
    [2013-07-25 16:26:43] (ERROR @ /connectors/system/log.php) Could not load class: TimelineSong from mysql.timelinesong.
    


    as soon as I open the manager activities manager page (not when saving the migxdb item...)

    I changed the file at core/model/modx/processors/system/log/getlist.class.php a bit to not try to getObject if it's not a native modSomething class, so at line 118 I inserted:

                if ( strpos($logArray['classKey'], 'mod') !== false ) {
                    $obj = $this->modx->getObject($logArray['classKey'],$logArray['item']);
                } else {
                    $obj = null;
                }
    


    which at least gets rid of the load errors like these:

    [2013-07-25 16:26:43] (ERROR @ /connectors/system/log.php) TimelineSong::load() is not a valid static method.
    [2013-07-25 16:26:43] (ERROR @ /connectors/system/log.php) Could not load class: TimelineSong from mysql.timelinesong.
    


    but the SQL errors stay.


    So the question is, what is the correct way to log actions from a custom component to the manager log?
      • 3749
      • 24,544 Posts
      I don't see anything wrong with your code. Are $task, $classname, and songId all strings?

      Maybe get() for your object overridden by a get() method that is calling a class method that might not be loaded?

      You might try doing loadClass() on the TimeLineSong class before issuing the logManageAction() call.
        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