We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49056
    • 3 Posts
    Hello all,

    Thank you in advance for your help. I am receiving the following message, but never modified any .php files and I am the only person with access:

    Fatal error: Call to a member function getMessage() on a non-object in /home4/vacantrd/public_html/wp-content/themes/medianews-theme/include/widgets.php on line 1621

    How do I correct and prevent from occurring in the future?

    My site is wwww.vacantroad.com

    I am very green with this stuff so please keep that in mind.

    Thanks,

    Jeff
      • 3749
      • 24,544 Posts
      That error usually happens when you try to call a method of an object that wasn't found.

      It almost always means that the author of the extra didn't include a sanity check to make sure the object was found before calling one of its methods.

      If you want to paste the code with that line (with about 10 lines or so before and after) in the widgets.php file, we may be able to give you a fix.

      What version of MODX are you running?
        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
        • 49056
        • 3 Posts
        Thanks BobRay,

        I'm not sure about either. I can open the widgets.php file, but am unable to identify line numbers. How do I do so?




        Quote from: BobRay at Sep 23, 2014, 11:46 PM
        That error usually happens when you try to call a method of an object that wasn't found.

        It almost always means that the author of the extra didn't include a sanity check to make sure the object was found before calling one of its methods.

        If you want to paste the code with that line (with about 10 lines or so before and after) in the widgets.php file, we may be able to give you a fix.

        What version of MODX are you running?
          • 3749
          • 24,544 Posts
          Well, you can count them by hand, but that's pretty tedious. wink

          One alternative is to use a code editor that displays them -- something like Notepad++, NetBeans, or something similar.

          You can install the Ace code editor in MODX -- I think it will work with files, but I'm not sure.

          In Cpanel's File Manager, there's usually a "Code Editor" option that should give you line numbers. That might be the easiest.
            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
            • 49056
            • 3 Posts
            So I copy and pasted into excel and the following are lines 1610 - 1633:

            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            $result = curl_exec($ch);
            $results = json_decode($result, true);

            curl_close($ch);

            if(isset($results) && array_key_exists( 'error', $results)){
            $px_facebook_message = 'Error - '.$results['error']['message'];
            if(isset($fb_count) && $fb_count <> ''){
            return $fb_count;
            } else {
            $px_facebook_message = $e->getMessage();
            }
            } else{
            if(isset($results['likes'])){
            set_transient($transName, (int)$results['likes'], $cacheTime);
            return (int)$results['likes'];
            }
            }
            } catch( Exception $e){
            if(isset($fb_count) && $fb_count <> ''){

            return $fb_count;
            } else {

            This is line 1621:

            $px_facebook_message = $e->getMessage();

            Thanks again,

            Jeff


            Quote from: BobRay at Sep 24, 2014, 05:00 PM
            Well, you can count them by hand, but that's pretty tedious. wink

            One alternative is to use a code editor that displays them -- something like Notepad++, NetBeans, or something similar.

            You can install the Ace code editor in MODX -- I think it will work with files, but I'm not sure.

            In Cpanel's File Manager, there's usually a "Code Editor" option that should give you line numbers. That might be the easiest.
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Yes, Ace does work for editing files from the MODX files manager.
                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