News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Cache accelerator not detected: PHP 7.0 and SMF 2.0.14

Started by GL700Wing, June 20, 2017, 09:43:17 AM

Previous topic - Next topic

GL700Wing

I have an SMF 2.0.14 forum and I've just changed from PHP 5.6 to PHP 7.0.

With PHP 5.6 I enabled the APC accelerator extension via the cPanel and confirmed that SMF was able to detect it (the message 'SMF has detected that your server has APC installed.' was displayed when I checked the cache settings).

Since switching to PHP 7.0 the message 'SMF has not been able to detect a compatible accelerator on your server.' is displayed when I check the cache settings even though I have enabled the APC accelerator extension via the cPanel.. I've also get the same message when I enable the memcached extension via cPanel.

Is there something else I need to configure either via cPanel or within SMF to enable caching with PHP 7.0?
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

GL700Wing

I've just confirmed that SMF 2.1 Beta 3 is able to detect cache accelerators for both PHP 7.0 and PHP 7.1 on the same host where my SMF 2.0.14 forum is installed so it seems this is a bug/oversight for SMF 2.0.14.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

GL700Wing

Using information I found in SMF 2.1 Beta 3 I have been able to get SMF 2.0.14 to recognise and use the APCu accelerator in PHP 7.0/7.1 by making the following code changes:

In ./Sources/Load.php
Find:
// Alternative PHP Cache, ahoy!
elseif (function_exists('apc_store'))
{
// An extended key is needed to counteract a bug in APC.
if ($value === null)
apc_delete($key . 'smf');
else
apc_store($key . 'smf', $value, $ttl);
}

Add After:
elseif (function_exists('apcu_store'))
{
// An extended key is needed to counteract a bug in APC.
if ($value === null)
apcu_delete($key . 'smf');
else
apcu_store($key . 'smf', $value, $ttl);
}


Find:
if (function_exists('apc_delete_file'))
@apc_delete_file($cachedir . '/data_' . $key . '.php');

Add After

if (function_exists('apcu_delete_file'))
@apcu_delete_file($cachedir . '/data_' . $key . '.php');


Find:
// This is the free APC from PECL.
elseif (function_exists('apc_fetch'))
$value = apc_fetch($key . 'smf');

Add After:
// This is the free APCu from PECL.
elseif (function_exists('apcu_fetch'))
$value = apcu_fetch($key . 'smf');


In ./Sources/ManageServer.php
Find:
elseif (function_exists('apc_store'))
$detected = 'APC';

Add After:
elseif (function_exists('apcu_store'))
$detected = 'APCu';



In ./Themes/default/languages/ManageSettings.english.php
Find:
<li>APC</li>
Add After:
<li>APCu</li>

Find:
$txt['detected_APC'] = '<strong style="color: green">SMF has detected that your server has APC installed.</strong>';
Add After:
$txt['detected_APCu'] = '<strong style="color: green">SMF has detected that your server has APCu installed.</strong>';
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Fisch.666

You can at least use APCu with PHP 7.0 on SMF 2.0.14 with the following package:

https://packages.debian.org/stretch/php-apcu-bc
https://pecl.php.net/package/apcu_bc

and SMF is detecting and using APCu without such code changes:

QuoteSMF has detected that your server has APC installed.

Using https://github.com/krakjoe/apcu/blob/master/apc.php confirms that APCu is utilized by SMF.

GL700Wing

Quote from: Fisch.666 on June 24, 2017, 10:40:47 AM
You can at least use APCu with PHP 7.0 on SMF 2.0.14 with the following package:

https://packages.debian.org/stretch/php-apcu-bc
https://pecl.php.net/package/apcu_bc

and SMF is detecting and using APCu without such code changes:

QuoteSMF has detected that your server has APC installed.

Using https://github.com/krakjoe/apcu/blob/master/apc.php confirms that APCu is utilized by SMF.
Thanks for this information - I'm using shared hosting so I'll have to find out if the provider is willing to install the backwards compatibility package.

However, given that an SMF 2.1 Beta 3 forum installed on the same domain using the same version of PHP can detect a number accelerators, it'd be great if the upcoming SMF 2.0.15 update had the support for accelerators that SMF 2.1 Beta 3  has.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Advertisement: