XenForo_Model_Counters::getBoardTotalsCounter();

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_users= XenForo_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 ?
 
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_users= XenForo_Model::create( 'XenForo_Model_Counters' )->getBoardTotalsCounter();
 
Last edited:
Rich (BB 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

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

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.
 
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...
 
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.
 
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.
 
Top Bottom