1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XenForo_Model_Counters::getBoardTotalsCounter();

Discussion in 'XenForo Development Discussions' started by LPH, Dec 17, 2014.

  1. LPH

    LPH Well-Known Member

    I have a class XenWordXFStats. Within the class is the following global and variable:

    PHP:
    global $XF
    $total_users
    $XF->getBoardTotalsCounter();
    The above works because I copied the getBoardTotalsCounter method from the XenForo_Model_Counters into the XenWord class file which is where the $XF comes from ....

    Anyway ... I'm wanting to remove the global $XF, and copied XenForo_Model_Counters code and simply call the XenForo code directly. So, I stripped out the getBoardTotalsCounter from the XenWord class file and called it as below.

    PHP:
    $total_usersXenForo_Model_Counters::getBoardTotalsCounter();
    This returns an error --
    Code:
    Fatal Error: Call to undefined method XenWordXFStats::getModelFromCache()
    I'm confused by this error. The getModelFromCache is not in XenWordXFStats (thus the error). Searching /library/XenForo there is getModelFromCache($class). So, I'm thinking that the $class is why it tries to call XenWordXFStats.

    How do I get around this ?
     
  2. LPH

    LPH Well-Known Member

    Duh .. almost there . but interfering with XenReviews.

    PHP:
            $XFusersModel XenForo_Model::create'XenForo_Model_Counters' );
            
    $total_users $XFusersModel->getBoardTotalsCounter();
    Disable XenReviews then this works. So, I must have duplicated other XenForo code in my XenWord class somewhere.

    Update: cleaner but still redeclare error with XenReviews

    PHP:
    $total_usersXenForo_Model::create'XenForo_Model_Counters' )->getBoardTotalsCounter();
     
    Last edited: Dec 17, 2014
  3. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    I can tell what's the error if I can look into XenReview's code...

    P.S. your code is perfectly okay, so this is something to do with XenReviews...
     
  4. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    You were calling a non-static method statically ;)
     
    LPH likes this.
  5. LPH

    LPH Well-Known Member

    Code:
    ErrorException: Fatal Error: Cannot redeclare class XFCP_XenReviews_XenForo_Model_Counters - /Applications/MAMP/htdocs/community/library/XenForo/Application.php(520) : eval()'d code:1
    Generated By: LPH, A moment ago
    Stack Trace
    #0 [internal function]: XenForo_Application::handleFatalError()
    #1 {main}
    Request State
    array (size=3)
      'url' => string 'http://lph/' (length=11)
      '_GET' =>
        array (size=0)
          empty
      '_POST' =>
        array (size=0)
          empty
    
    Actually, I ran into this error before and it was my code in my XenWord class duplicated with XenReviews. But I don't see duplication this time.
     
  6. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    Do a debug and check the files that are being included... XenForo_Application::resolveDynamicClass() caches the proxy classes so see where else the proxy class 'XenReviews_Model_Counters' is being called before your script calls the model...
     
  7. LPH

    LPH Well-Known Member

    Thank you for the idea. I started a thread few weeks ago on using debug in phpstorm to trace errors and to understand XenForo. I'm not sure how to use debug in this fashion - I usually just look at the error :eek:

    I'll fuss with it today and see if I can understand.
     
  8. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

  9. LPH

    LPH Well-Known Member

    Thank you. Tried and failed; The WordPress page loaded without any information. So - it's back to reading about debug for me :)

    I appreciate the help.
     

Share This Page