• Resolved woskyp

    (@woskyp)


    Hello, I have a problem with the class UserAccessManager.class.php.
    I have this message : Warning: Creating default object from empty value in /home/ecoleste/public_html/wp-content/plugins/user-access-manager/class/UserAccessManager.class.php on line 1752

    When I go to see the class, the problem seem to come from the function _getTerm

    The code is this one, line 1752 is the following code : $oTerm->isEmpty = false;

    Here all the code of this function :

    protected function _getTerm($sTermType, $oTerm)
        {
            $aUamOptions = $this->getAdminOptions();
            $oUamAccessHandler = $this->getAccessHandler();
           
       <strong> $oTerm->isEmpty = false;</strong>
         
            $oTerm->name .= $this->adminOutput('term', $oTerm->term_id);
           
            if ($sTermType == 'post_tag'
                || ( $sTermType == 'category' || $sTermType == $oTerm->taxonomy)
                && $oUamAccessHandler->checkObjectAccess('category', $oTerm->term_id)
            ) {
                if ($this->atAdminPanel() == false
                    && ($aUamOptions['hide_post'] == 'true'
                    || $aUamOptions['hide_page'] == 'true')
                ) {
                    $iTermRequest = $oTerm->term_id;
                    $sTermRequestType = $sTermType;
                   
                    if ($sTermType == 'post_tag') {
                        $iTermRequest = $oTerm->slug;
                        $sTermRequestType = 'tag';
                    }
                   
                    $aArgs = array(
                        'numberposts' => - 1,
                        $sTermRequestType => $iTermRequest
                    );
                   
                    $aTermPosts = get_posts($aArgs);
                    $oTerm->count = count($aTermPosts);
                   
                    if (isset($aTermPosts)) {
                        foreach ($aTermPosts as $oPost) {
                            if ($aUamOptions['hide_'.$oPost->post_type] == 'true'
                                && !$oUamAccessHandler->checkObjectAccess($oPost->post_type, $oPost->ID)
                            ) {
                                $oTerm->count--;
                            }
                        }
                    }
                   
                    //For post_tags
                    if ($sTermType == 'post_tag' && $oTerm->count <= 0) {
                        return null;
                    }
                   
                    //For categories
                    if ($oTerm->count <= 0
                        && $aUamOptions['hide_empty_categories'] == 'true'
                        && ($oTerm->taxonomy == "term"
                        || $oTerm->taxonomy == "category")
                    ) {
                        $oTerm->isEmpty = true;
                    }
                   
                    if ($aUamOptions['lock_recursive'] == 'false') {
                        $oCurCategory = $oTerm;
                       
                        while ($oCurCategory->parent != 0) {
                            $oCurCategory = get_term($oCurCategory->parent, 'category');
                           
                            if ($oUamAccessHandler->checkObjectAccess('term', $oCurCategory->term_id)) {
                                $oTerm->parent = $oCurCategory->term_id;
                                break;
                            }
                        }
                    }
                }
    
                return $oTerm;
            }
           
            return null;
        }

    Can anyone could help me to resolve this problem?

    Thanks per advance for your help 😉

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

    Not tested, but quite sure that this happens because the function is called with no object $oTerm defined. This is not normal but,
    the most simple to walk around his to add at beginning :

    if ($oTerm=='null') return 'null';

    Then change code to :

    protected function _getTerm($sTermType, $oTerm)
        {
            if ($oTerm=='null') return 'null';
    
            $aUamOptions = $this->getAdminOptions();
            $oUamAccessHandler = $this->getAccessHandler();
           
            $oTerm->isEmpty = false;
         
            $oTerm->name .= $this->adminOutput('term', $oTerm->term_id);
    ....

    It is sure that if there is an error (no time to check) in the call of the function, which don’t define an “term” which should be you will miss this term. This can be the true bug. What I offer is a work around for the error displayed.

    Best regards

    Trebly

    Thread Starter woskyp

    (@woskyp)

    Hi !
    Thanks for your response. I’ve tried it but unfortunately it doesn’t work 🙁
    The value of oTerm seems to be not null, because I try to put an echo to see if the program go into the proposed function, but nothing appear… So I suppose that the problem is different.
    Does anyone have another solution?

    Thanks !

    • This reply was modified 9 years, 7 months ago by woskyp.
    Thread Starter woskyp

    (@woskyp)

    I’ve found the solution.
    In fact, in my menu, there was a category with no original name. oTerm is the object corresponding of each part of the menu. So empty value in my case 😉

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘problem with UserAccessManager.class.php’ is closed to new replies.