Support Forum

Trying to get property of non-object

BO boborg
boborg
Member

In sferrorlog in the db I am getting a lot of these 

file: /simple-press/forum/content/sp-common-view-functions.php<br />line: 104<br />function: sp_SectionStart<br />Notice | Trying to get property of non-object

file: /simple-press/forum/content/sp-topic-view-functions.php<br />line: 671<br />function: sp_PostIndexUserRank<br />Notice | Trying to get property of non-object

Any ideas what is causing this and how do I fix it?

The forum in question is http://digitalt.tv/forum/ (Version 5.2.1)

16 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

I’m looking into it. I might have goofed!

MP Mr Papa
Mr Papa
Member

looks like we might want to do a quick 5.2.2 to resolve these… discussing it now..

YS Yellow Swordfish
Yellow Swordfish
Member

Update released to address this. Sorry about that and thanks for the quick find.

TY tyleryoungblood
tyleryoungblood
Member

Ok, so I’m having the same (or at least a very similar) issue. I had a 2gb error log with over 2 million entries (which I truncated) and within an hour the error log is back up to over 2k errors. All the errors have the same error message:

id error_date error_type error_text
2315 2013-01-03 17:18:21 php file: /simple-press/sp-api/sp-api-auths.php<br />line: 32<br />function: sp_get_auth<br />Notice | Trying to get property of non-object

I had the errors before updating to wp 3.5 and SP 5.2.2

I’ve since updated (successfully as far as I can tell) to the most current version of both WP and SP. I did get one error message while updating SP plugins, which was:

Fatal error: call to undefined function sp_tinymce_do_upgrade() in …. wp-content/sp-resoursec/forum-plugins/tinymce-richtext/sp-tinymce-plugin.php on line 88

However, when I went back to my update plugins page all of the plugins show that they’ve successfully been updated.

I’m mostly worried about the error log filling up as it breaks my scheduled backups (which is how I noticed it in the first place).

Any ideas?

MP Mr Papa
Mr Papa
Member

as posted in other topics, the error log limited to 50 last errors was broken…  it was fixed in 5.2.2… so now the error log will stay at 50…  you should clear you error log on forum – toolbox – error log… and then keep an eye on it to make sure it doesnt grow past 50 entries…

dont worry about the tinymce upgrade notice… it happens sometimes in this one upgrade because we moved the location of the upgrade file…  doesnt affect anything… 

TY tyleryoungblood
tyleryoungblood
Member

I cleared my error log and it seems that my error log is indeed staying at 50 errors (well, 51 notices actually). So that’s good. Thank you!

Any idea what’s causing the notices? I’d like to fix it so that my error log can be used for other (potentially important) errors, like database errors and whatnot. 

MP Mr Papa
Mr Papa
Member

That same error?? line 32 of sp-api-auths.php??

Not sure I understand how that error is occurring… do you know when it is occurring? can you ‘make’ it happen?

also, keep in mind this error log we are talking about is our error log in one of our database tables… its not precluding anything in your normal php error log…

TY tyleryoungblood
tyleryoungblood
Member

Well, it’s been 2 days and my error log is holding steady at 51 entries, but the auto-increment id is showing that I’ve had 184,204 notices since truncating the table two days ago. So it’s not a single notice or error per page view (I get about 100k page view per month, not per day) so I’m a little stumped as to what’s causing the error. I can’t really make it happen, it happens all on its own … frequently.

I guess I’m not too worried about it, but I wish I knew what it was.

Full Texts id error_date error_type error_text
Edit Delete 184204 2013-01-05 19:14:02 php file: /simple-press/sp-api/sp-api-auths.php<br />l…
MP Mr Papa
Mr Papa
Member

we had that occurring many months and versions ago, but it has not been occurring for folks… and looking at the code, I dont understand how it would happen either…

which is why really need some idea as to when its happening…  any custom theme or plugin work?  have you tried visiting as user or guest, vice admin?

this is the line of code:

        if (empty($spThisUser->ID) && $sfglobals[‘auths’][$sfglobals[‘auths_map’][$check]]->ignored) $auth = 0;

but not sure and cannot explain why any of the objects (there is two in that line) would be undefined…

have you created or customized any of the permissions?

maybe try going to forum – toolbox – housekeeping and try resetting the auths cache.. maybe something off there…

TY tyleryoungblood
tyleryoungblood
Member

I reset the authors cache and I’m still getting the notices.

The only customization I have made to the forum that I can think of is adding  adsense adds using the built in hooks.

It looks like the notices show up whenever admins or subscribers view the site. Possibly guests also but it’s hard to tell.

I could create an admin account for you (actually, I think you already have one from a problem a few years ago) if you want to take a look around. Let me know if you’re interested in figuring it out. If not, no biggie. My OOP skills are a bit weak otherwise I’d try to dig into it more.

 

MP Mr Papa
Mr Papa
Member

can you post the adsense code you wrote?  worth a check to make sure its proper…

TY tyleryoungblood
tyleryoungblood
Member

Basically I followed the directions found on this post.

To make sure my changes didn’t get overwritten with an update I followed the directions for making a child theme.

Then I edited my spFunctions.php file to include my adsense code (ignore the obfuscating XX’s):

<?php
# --------------------------------------------------------------------------------------
#
#    Simple:Press Theme custom function file
#    Theme        :    Default
#    File        :    custom functions
#    Author        :    Simple:Press
#
#    The 'functions' file can be used for custom functions & is loaded with each template
#
# --------------------------------------------------------------------------------------

add_action('init', 'spmytheme_textdomain');

# load the theme textdomain for tranlations
function spmytheme_textdomain() {
    sp_theme_localisation('spmytheme');
}

if (function_exists('sp_FontResizer')) {
    add_action('sph_BeforeDisplayStart', 'spmytheme_spShowFontResize');
}

function spmytheme_spShowFontResize() {
    $tipMinus = __sp('decrease forum font size');
    $tipReset = __sp('reset forum font size');
    $tipPlus  = __sp('increase font size');
    sp_FontResizer('tagClass=spFontSizeControl spRight', $tipMinus, $tipReset, $tipPlus);
    sp_InsertBreak('direction-right');
}

//create a function for placing adsense code in forum
//problem-with-post-edit-buttonttp://simple-press.com/support-forum/sp5-coding-questions/adsense-code/page-3/
function spAdsense728x90() {
    echo '<center><script type="text/javascript"><!--
                google_ad_client = "ca-pub-XXXXXXXXXXXXXXXXXX";
                /* PIM Forum 728x90 */
                google_ad_slot = "00XXXX2059";
                google_ad_width = 728;
                google_ad_height = 90;
                //-->
                </script>
                    <script type="text/javascript"
                    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
                </script>
            </center>';
}

?>

And then I called the function in my spTopicView.php file (line 155). Sorry for posting the entire file, but since I don’t know where the error might be I though’t I’d err on the side of overkill.

<?php
# --------------------------------------------------------------------------------------
#
#    Simple:Press Template
#    Theme        :    Default
#    Template    :    topic
#    Author        :    Simple:Press
#
#    The 'topic' template is used to display the Topic/Post Index Listing
#
# --------------------------------------------------------------------------------------


    # == ADD POST FORM - OBJECT DEFINITION ========================
    $addPostForm = array(
        'tagClass'                => 'spForm',
        'hide'                    => 1,
        'controlFieldset'        => 'spEditorFieldset',
        'controlInput'            => 'spControl',
        'controlSubmit'            => 'spSubmit',
        'labelHeading'            => __sp('Add Reply'),
        'labelGuestName'        => __sp('Guest name (required)'),
        'labelGuestEmail'        => __sp('Guest email (required)'),
        'labelModerateAll'        => __sp('NOTE: new posts are subject to administrator approval before being displayed'),
        'labelModerateOnce'        => __sp('NOTE: first posts are subject to administrator approval before being displayed'),
        'labelSmileys'            => __sp('Smileys'),
        'labelOptions'            => __sp('Options'),
        'labelOptionLock'        => __sp('Lock this topic'),
        'labelOptionPin'        => __sp('Pin this post'),
        'labelOptionTime'        => __sp('Edit post timestamp'),
        'labelMath'                => __sp('Math Required'),
        'labelMathSum'            => __sp('What is the sum of'),
        'labelPostButtonReady'    => __sp('Submit Reply'),
        'labelPostButtonMath'    => __sp('Do Math To Save'),
        'labelPostCancel'        => __sp('Cancel')
    );

    # == EDIT POST FORM - OBJECT DEFINITION ========================
    $editPostForm = array(
        'tagClass'                => 'spForm',
        'controlFieldset'        => 'spEditorFieldset',
        'controlInput'            => 'spControl',
        'controlSubmit'            => 'spSubmit',
        'labelHeading'            => __sp('Edit Post'),
        'labelSmileys'            => __sp('Smileys'),
        'labelPostButton'        => __sp('Save Edited Post'),
        'labelPostCancel'        => __sp('Cancel')
    );
    # ==============================================================


    # Load the forum header template - normally first thing
    # ----------------------------------------------------------------------
    sp_SectionStart('tagClass=spHeadContainer', 'head');
        sp_load_template('spHead.php');
    sp_SectionEnd('', 'head');

    sp_SectionStart('tagClass=spBodyContainer', 'body');

        # Start the 'topicView' section
        # ----------------------------------------------------------------------
        sp_SectionStart('tagClass=spListSection', 'topicView');

            # Set the Topic
            # ----------------------------------------------------------------------
            if (sp_this_topic()):
                # Start the 'pagelinks' section
                # ----------------------------------------------------------------------
                sp_SectionStart('tagClass=spPlainSection', 'pageLinks');
                    sp_PostNewButton('tagId=spPostNewButtonTop&tagClass=spButton spRight', __sp('Add Reply'), __sp('Add a new post in this topic'), __sp('This topic is locked'));
                    sp_PostNewTopicButton('tagId=spPostNewTopicButtonTop&tagClass=spButton spRight', __sp('Add Topic'), __sp('Start a new topic'), __sp('This forum is locked'));
                    sp_PostIndexPageLinks('', __sp('Page: '), __sp('Jump to page %PAGE% of this topic'));
                sp_SectionEnd('tagClass=spClear', 'pageLinks');

                # Start the 'topicHeader' section
                # ----------------------------------------------------------------------
                sp_SectionStart('tagClass=spTopicViewSection', 'topic');
                    sp_TopicHeaderRSSButton('tagClass=spButton spRight', __sp('Topic RSS'), __sp('Subscribe to the RSS feed for this topic'));
                    if (function_exists('sp_RelatedTopicsButton')) sp_RelatedTopicsButton('tagClass=spButton spRight', __sp('Related Topics'), __sp('Get a list of related topics based on tags for this topic'));
                    sp_TopicHeaderIcon('tagClass=spHeaderIcon spLeft');
                    sp_TopicHeaderName('tagClass=spHeaderName');
                    if (function_exists('sp_TopicHeaderShowBlogLink')) sp_TopicHeaderShowBlogLink('', __sp('Read the original blog post'), __sp('Click to goto original blog post'));

                    sp_InsertBreak();

                    if (function_exists('sp_TopicTagsList') || function_exists('sp_TopicStatus')) {
                        if (function_exists('sp_TopicTagsList')) sp_TopicTagsList('tagClass=spTopicTagsList spLeft', __sp('Tags: '));
                        if (function_exists('sp_TopicStatus')) sp_TopicStatus('tagClass=spTopicViewStatus spButton spLeft', __sp('Search for other topics with this status'), __sp('Status: '));
                        sp_InsertBreak();
                    }

                    sp_SectionStart('tagClass=spTopicPostContainer', 'postlist');

                        # Start the Post Loop
                        # ----------------------------------------------------------------------
                        if (sp_has_posts()) : while (sp_loop_posts()) : sp_the_post();

                            # Start the 'post' section
                            # ----------------------------------------------------------------------
                            sp_SectionStart('tagClass=spTopicPostSection', 'post');

                                sp_PostIndexAnchor();

                                sp_PostForumToolButton('', '', __sp('Open the forum toolset'));

                                # Column 1 of the post row
                                # ----------------------------------------------------------------------
                                sp_ColumnStart('tagClass=spUserSection spLeft&width=15%&height=50px');
                                    sp_PostIndexUserDate('tagClass=spPostUserDate spCenter');
                                    sp_UserAvatar('tagClass=spPostUserAvatar spCenter&context=user', $spThisPostUser);
                                    sp_PostIndexUserName('tagClass=spPostUserName spCenter');
                                    sp_PostIndexUserLocation('tagClass=spPostUserLocation spCenter');
                                    sp_PostIndexUserRank('tagClass=spPostUserRank spCenter');
                                    sp_PostIndexUserSpecialRank('tagClass=spPostUserSpecialRank spCenter');
                                    sp_PostIndexUserPosts('tagClass=spPostUserPosts spCenter', __sp('Forum Posts: %COUNT%'));
                                    sp_PostIndexUserRegistered('tagClass=spPostUserRegistered spCenter', __sp('Member Since:<br /> %DATE%'));
                                    sp_PostIndexUserStatus('tagClass=spCenter spPostUserStatus', __sp('Online'), __sp('Offline'));
                                    sp_SectionStart('tagClass=spCenter', 'user-identities');
                                        sp_PostIndexUserWebsite('', __sp('Visit my website'));
                                        sp_PostIndexUserTwitter('', __sp('Follow me on Twitter'));
                                        sp_PostIndexUserFacebook('', __sp('Connect with me on Facebook'));
                                        sp_PostIndexUserMySpace('', __sp('See MySpace'));
                                        sp_PostIndexUserLinkedIn('', __sp('My LinkedIn network'));
                                        sp_PostIndexUserYouTube('', __sp('View my YouTube channel'));
                                        sp_PostIndexUserGooglePlus('', __sp('Interact with me on Google Plus'));
                                    sp_SectionEnd('', 'user-identities');
                                sp_ColumnEnd();

                                # Column 2 of the post row
                                # ----------------------------------------------------------------------
                                sp_ColumnStart('tagClass=spPostSection spRight&width=84%');

                                    # Start the 'post' section
                                    # ----------------------------------------------------------------------
                                    sp_SectionStart('tagClass=spPostActionSection', 'action');
                                        sp_GoToTop('tagClass=spRight spGoToTop&iconClass=spIcon', '', __sp('Go to Top'));
                                        sp_PostIndexPinned('tagClass=spStatusIcon spLeft', __sp('This post is pinned'));
                                        if (function_exists('sp_PostIndexPostByEmail')) sp_PostIndexPostByEmail('tagClass=spStatusIcon spLeft', 'This post was sent by email');
                                        sp_PostIndexNumber('tagClass=spLabelBordered spLeft');
                                        sp_PostIndexEditHistory('tagClass=spButton spLeft', '', __sp('Edited by %USER% on %DATE%'), __sp('View edit history'));
                                        sp_PostIndexPermalink('tagClass=spButton spLeft', '', __sp('The post permalink'));
                                        sp_PostIndexPrint('tagClass=spButton spLeft', '', __sp('Print this post'));
                                        sp_PostIndexNewPost('tagClass=spLabelBordered spLeft', __sp('New'));
                                        if (function_exists('sp_PostIndexRatePost')) sp_PostIndexRatePost('tagClass=spLabelBordered spPostRating spRight');
                                        if (function_exists('sp_PostIndexReportPost')) sp_PostIndexReportPost('tagClass=spButton spRight', __sp('Report'), __sp('Report this post to admin'));
                                        sp_PostIndexQuote('tagClass=spButton spRight', __sp('Quote'), __sp('Quote this post and reply'));
                                        sp_PostIndexEdit('tagClass=spButton spRight', __sp('Edit'), __sp('Edit this post'));
                                        sp_PostIndexDelete('tagClass=spButton spRight', 'Delete', 'Delete this post');
                                        if (function_exists('sp_PostIndexSendPm')) sp_PostIndexSendPm('tagClass=spButton spRight', __sp('PM'), __sp('Send PM to this user'));
                                    sp_SectionEnd('', 'action');
                                    sp_InsertBreak();

                                    sp_SectionStart('tagClass=spPostContentSection', 'content');
                                        //adsense code
                                        if($spTopicView->currentPost==1 OR $spTopicView->currentPost==5){ //only display for fist post
                                            if (function_exists('spAdsense728x90')) spAdsense728x90();
                                        }
                                        
                                        sp_PostIndexContent('', __sp('Awaiting Moderation'));
                                    sp_SectionEnd('', 'content');
                                    sp_InsertBreak();

                                    sp_PostIndexUserSignature('tagClass=spPostUserSignature spCenter&maxHeightBottom=55');
                                    sp_InsertBreak();

                                sp_ColumnEnd();

                                sp_InsertBreak();

                            sp_SectionEnd('', 'post');

                        endwhile; else:
                            sp_NoPostsInTopicMessage('tagClass=spMessage', __sp('There are no posts in this topic'));
                        endif;

                    sp_SectionEnd('', 'postlist');

                sp_SectionEnd('', 'topic');

                # Start the 'pagelinks' section
                # ----------------------------------------------------------------------
                sp_SectionStart('tagClass=spPlainSection', 'pageLinks');
                    sp_PostNewButton('tagId=spPostNewButtonBottom&tagClass=spButton spRight', __sp('Add Reply'), __sp('Make a new post in this topic'), __sp('This topic is locked'));
                    sp_PostNewTopicButton('tagId=spPostNewTopicButtonBottom&tagClass=spButton spRight', __sp('Add Topic'), __sp('Start a new topic'), __sp('This forum is locked'));
                    sp_PostIndexPageLinks('', __sp('Page: '), __sp('Jump to page %PAGE% of this topic'));
                    sp_InsertBreak();
                sp_SectionEnd('', 'pageLinks');

                # Start the 'editor' section
                # ----------------------------------------------------------------------
                sp_SectionStart('tagClass=spHiddenSection', 'editor');
                    sp_PostEditorWindow($addPostForm, $editPostForm);
                sp_SectionEnd('', 'editor');
            else:
                sp_NoTopicMessage('tagClass=spMessage', __sp('Access denied - you do not have permission to view this page'), __sp('The requested topic does not exist'));
            endif;

        sp_SectionEnd('', 'topicView');

    sp_SectionEnd('', 'body');

    # Load the forum footer template - normally last thing
    # ----------------------------------------------------------------------
    sp_SectionStart('tagClass=spFootContainer', 'foot');
        sp_load_template('spFoot.php');
    sp_SectionEnd('', 'foot');
?>

My ads are displaying properly, but I guess I could have made a mistake in my child theme creation?