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

XF 1.2 Site broke after upgrading to PHP 5.3

Rho Delta

Well-known member
#1
I get this error and nothing else:
Code:
An exception occurred: The apc extension must be loaded for using this backend ! in /home/mike/public_html/library/Zend/Cache.php on line 209

Zend_Cache::throwException() in Zend/Cache/Backend/Apc.php at line 59
Zend_Cache_Backend_Apc->__construct() in Zend/Cache.php at line 153
Zend_Cache::_makeBackend() in Zend/Cache.php at line 94
Zend_Cache::factory() in XenForo/Application.php at line 718
XenForo_Application->loadCache()
call_user_func_array() in XenForo/Application.php at line 921
XenForo_Application->lazyLoad() in XenForo/Application.php at line 952
XenForo_Application::get() in XenForo/Application.php at line 1376
XenForo_Application::getCache() in XenForo/Model.php at line 146
XenForo_Model->_getCache() in XenForo/Model/DataRegistry.php at line 81
XenForo_Model_DataRegistry->getMulti() in XenForo/Dependencies/Abstract.php at line 144
XenForo_Dependencies_Abstract->preLoadData() in XenForo/FrontController.php at line 127
XenForo_FrontController->run() in /home/mike/public_html/index.php at line 13
How do I fix this please?
 

Mike

XenForo developer
Staff member
#3
You've setup APC caching in config.php but your server isn't running APC. You need to sort one of those two things. Preferably enabling APC on the server. Note that you likely need to update or recompile APC against the current version of PHP.
 

Rho Delta

Well-known member
#4
You've setup APC caching in config.php but your server isn't running APC. You need to sort one of those two things. Preferably enabling APC on the server. Note that you likely need to update or recompile APC against the current version of PHP.
Thanks for the info. Do you have the chart that shows the differences between APC, DSO and the other options to show my host provider?
 

Mike

XenForo developer
Staff member
#5
I assume you mean DSO vs FastCGI and the like as APC is something totally different.

But no, I do not. There are various discussions about it on other forums, but the exact choice may vary quite a lot in your use case and server environment.
 

Rho Delta

Well-known member
#6
I assume you mean DSO vs FastCGI and the like as APC is something totally different.

But no, I do not. There are various discussions about it on other forums, but the exact choice may vary quite a lot in your use case and server environment.
Looks like they changed me to eaccelerator without telling me:

It is likely that this change was made when it was brought to your attention that support for APC had ended. APCU is now the new incarnation, and we have yet to investigate it in regards to stability and backwards comparability.
What is APCU? Will it work with XF?
 

Mike

XenForo developer
Staff member
#7
APCu is mostly for PHP 5.5. If your host only flipped to PHP 5.3, I don't see a particular reason to ditch APC but that's their prerogative.

I do not know if APCu works. In general, we don't recommend using APC for data caching due to the (default) behavior when the cache fills up. If you're on a shared server, I wouldn't enable caching in config.php unless you know the system well.
 

Sim

Well-known member
#8
I do not know if APCu works. In general, we don't recommend using APC for data caching due to the (default) behavior when the cache fills up. If you're on a shared server, I wouldn't enable caching in config.php unless you know the system well.
I recently moved 5 of my smaller XenForo forums to a new VPS running PHP 5.5 using the built-in Zend OpCache and APCu. Works fine.

These are small forums though, so caching load is light - haven't tried it on one of my large sites yet.

A quick APC primer for those people not familiar with the details:

APC provides two services: opcode caching and user code (application) caching.

Opcode caching is an automated process of taking compiled code (opcode) that the PHP interpreter generates and caching it, saving load on the PHP server since it doesn't need to compile the code for every page request. It really is a quick and easy way (in most cases) to save on server load. There is nothing at an application level required to configure and use opcode caching - your application doesn't need to know about it.

User code caching is where PHP applications can choose to store frequently accessed information (eg from a database lookup) in the memory cache for quick access - thus reducing the requirement to access the database or other "slow" datastore every page view.

There are some known bugs with APC in PHP 5.4 that manifest themselves in XenForo (for example, registration page causes PHP to crash, user profile pages cause PHP to crash) - which is the reason I decided to try PHP 5.5 in the first place.

I would strongly recommend against using PHP 5.4 with APC if you are running XenForo.

In PHP 5.5, there is now an opcode cache built in to PHP - "Opcache" (which is originally from Zend's Optimizer+ apparently). Once you install PHP 5.5, in most cases (depending on how PHP was compiled), you just need to enable it in php.ini to get opcode caching. Apparently PHP 5.5's Opcache is superior to APC in management of the cache.

However, PHP 5.5's Opcache does NOT provide user code caching capability. This means that if you have written your application to take advantage of user code caching using APC, you can't upgrade to PHP 5.5 because APC is not available. You either need to re-write your code to use a different cache engine, or find a drop-in replacement for APC.

Fortunately, XenForo comes with configurable options for application-level caching, meaning you can easily swap out APC for a different cache engine if you choose.

However, there is an alternative available for PHP 5.5 - APCu, which has been written as a drop-in replacement for the user code caching component of APC. APCu does not provide opcode caching.

APCu is intended to be API compatible with APC, so you can just use it just like would use APC.