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,
    I'm using
    Revolution 2.2.1-dev from git
    WAMP server install on Windows7
    PHP 5.3.8
    MySQL server: 5.5.16-log
    MySQL Client : mysqlnd 5.0.8-dev - 20102224 - $Revision: 310735 $

    I upgraded yesterday (from git as usual), run setup all worked fine.
    This morning having a look at my MODx error.log I saw this warning:
    [2012-01-17 09:45:07] (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-17 09:45:07] (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
    


    It's just a warning, so I expect it would not have some undesirable effect(s)... Is there something to do to correct it ?
    Cheers
    • I had a bunch of those after installing the latest nightly today. It didn't seem to have any affect on anything, though. I can log out and log in just fine.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
      • Ok, it turns out that the default value for the session_stale field in the user table is NULL. Until permissions get flushed this value will remain NULL. Once permissions are flushed, it will contain a serialized array something like a:1:{i:1;s:3:"web";}

        Since array_search requires an array to search, that initial NULL value is invalid.

        To at least temporarily stop the constant errors, I made a small addition to the moduser.class.php file, adding a conditional before the array_search block:

         
                    $staleContexts = $this->get('session_stale');
                    if($staleContexts) {
                        $stale = array_search($context, $staleContexts);
                        if ($stale !== false) {
                            $reload = true;
                            $staleContexts = array_diff($staleContexts, array($context));
                            $this->set('session_stale', $staleContexts);
                            $this->save();
                        }
                    }
                }
        


        I don't think this will have any effect other than to skip the whole thing if it's NULL or otherwise empty, but given the convoluted nature of this whole can of worms I wouldn't want to bet on it. It would probably be better to make a plugin to flush permissions after the user is saved, at least until a more permanent fix is done.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org