We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1778
    • 659 Posts
    Hi all
    After my last upgrade I have a bunch of error message in my error.log. The file grows ervery time I make in action (load a page, change a page, edit something in the manager) with always the same message
    [2012-01-19 15:55:48] (ERROR @ C:\wamp\www\revo22\core\model\modx\moduser.class.php : 122) PHP warning: array_search() expects parameter 2 to be array, null given
    [2012-01-19 15:55:48] (ERROR @ C:\wamp\www\revo22\core\model\modx\moduser.class.php : 125) PHP warning: array_diff() [<a href='function.array-diff'>function.array-diff</a>]: Argument #1 is not an array
    


    The REAL problem is now, there is nothing else put in the log... Trying to put a simple
    $modx->log(xPDO::LOG_LEVEL_ERROR, 'some msg here.');
    

    in a basic postHook (I know it works well) and nothing in the log ! What can I do ? This behaviour makes debugging very hard....

    Everything else works fine, except this probelm...
    Cheers
      • 3749
      • 24,544 Posts
      I don't know of a fix for that bug (though one should be out soon), but another way to debug is to create a chunk called debug and put something like this at the top of your snippet or plugin (or 'include' it there):

      if (!function_exists("my_debug") && $scriptProperties['debug']) {
          function my_debug($message, $clear = false)
          {
              global $modx;
      
              $chunk = $modx->getObject('modChunk', array('name' => 'Debug'));
              if (!$chunk) {
                  $chunk = $modx->newObject('modChunk', array('name' => 'Debug'));
                  $chunk->setContent('');
                  $chunk->save();
                  $chunk = $modx->getObject('modChunk', array('name' => 'Debug'));
              } else {
                  if ($clear) {
                      $content = '';
                  } else {
                      $content = $chunk->getContent();
                  }
              }
              $content .= $message . "\n";
              $chunk->setContent($content);
              $chunk->save();
          }
      }


      Then, if the the snippet tag has &debug=`1`, my_debug($msg) will append the message to the chunk content and my_debug($msg, true) clear the chunk and add the message.


      ---------------------------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
      MODx info for everyone: http://bobsguides.com/MODx.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
        • 1778
        • 659 Posts
        Hello BobRay

        Thanks for the tip ! It will be useful ^_^
        Cheers