We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44922
    • 131 Posts
    We upgraded Modx some weeks ago using UpgradeModx and have been gradually tracking down bugs. One or two persist, but they have the effect of taking out bits of the manager - maybe the Snippets won't load or the Template Variables in the Element Tree, for example. Sometimes the whole manager shows Error 500. In all cases, using SSH to ensure core/cache is totally empty sorts the problem - temporarily. It wouldn't be a huge issue but various snippets stop working which logged-in front end users need, so it's a pain.

    We see two errors thrown, one is Smarty related the other Extended Fields. I suspect the Smarty one is the culprit but don't understand enough.

    We see
    [Mon Apr 10 07:52:11 2017] [warn] [client xx.xx.xx.xx] mod_fcgid: stderr: PHP Fatal error:  Uncaught  --> Smarty: unable to write file /home/g/public_html/core/cache/mgr/smarty/default/wrt58eb39ab222b83_48732074 <-- 
    [Mon Apr 10 07:52:11 2017] [warn] [client xx.xx.xx.xx] mod_fcgid: stderr:   thrown in /home/g/public_html/core/model/smarty/sysplugins/smarty_internal_write_file.php on line 46
    

    with lines 43 - 46 being
     $_tmp_file = $_dirpath . DS . str_replace(array('.', ','), '_', uniqid('wrt', true));
            if (!file_put_contents($_tmp_file, $_contents)) {
                error_reporting($_error_reporting);
                throw new SmartyException("unable to write file {$_tmp_file}");


    The extended profiles error is
    
    [Mon Apr 10 05:59:32 2017] [warn] [client xx.xx.xx.xx] mod_fcgid: stderr: PHP Fatal error:  Call to a member function get() on a non-object in /home/g/public_html/core/cache/includes/elements/modsnippet/91.include.cache.php on line 8


    with lines 7 & 8 being

    $profile = $modx->user->getOne('Profile');
    $extended = $profile->get('extended');


    Any help appreciated.
      • 3749
      • 24,544 Posts
      Leftover browser cookies can cause weird effects in the Manager after an upgrade.

      On the "Call to a member function..." error, it looks like you have a user with no profile. That can happen if a user is created in code without creating a corresponding modUserProfile.

      Changing the code to this should tell you who the user is (and the sanity check should be there in the first place):

      $profile = $modx->user->getOne('Profile');
      if ($profile) {
          $extended = $profile->get('extended');
      } else {
         $modx->log(modX::LOG_LEVEL_ERROR, ' User has no profile. Username = ' . $modx->user->get('username');
      }
      
        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
        • 44922
        • 131 Posts
        Thanks, Bob. Will implement and report back.