So it looks like running supercache on PHP 7 won't work. I got this back from support at Acquia:

Unfortunately, starting with PHP 7.0, APCu removed the option for full backwards compatibility with APC that existed with APCu in PHP 5.5 and 5.6. This means that PHP7 only accepts new APCu functions (for example apc_fetch()).

The best solution for the time being would be for your own modules or contrib modules to account for both (e.g. if apc_fetch() exists, use that, else apcu_fetch()). This of course would be true for all apc_* functions.

Not sure how to fix this or if there's work around ?

Comments

swentel created an issue. See original summary.

caspervoogt’s picture

See if this patch works for you. It at least does not cause errors on my end.

caspervoogt’s picture

StatusFileSize
new4.84 KB
caspervoogt’s picture

I noticed an issue with Pathauto, seemingly caused by Supercache. I was experiencing the issue described here. I applied the patches there (to the dev version of Pathauto), yet that did not fix it. Then I uninstalled Supercache (the only module I played with recently), and the URL alias checkbox started behaving normally again. Just to be really sure, I then re-enabled Supercache to see if the regression would recur; it did. I also tested it with PHP 5.5.9 as well as PHP 7, and it happens in both cases.

I did go through the module some, and suspect the backend caching (ChainedFastBackend) is somehow to blame. I couldn't make much sense out of it all though.

I have had to uninstall Supercache for now.

swentel’s picture

Thanks, will test it out next week. I'm 'lucky' I'm not using pathauto, so I can get away with it for now.

+++ b/modules/supercache/src/Cache/ApcuRawBackend.php
@@ -237,10 +278,23 @@ public function removeBin() {
+      apc_inc($key, $increment, $success);
+    }
+    ¶
     if (!$success) {

nitpick - spaces, o well :)

andypost’s picture

Status: Active » Needs work
+++ b/modules/supercache/src/Cache/ApcuRawBackend.php
@@ -45,12 +45,22 @@ protected function getTtl($expire) {
+    if(function_exists('apcu_store')){

@@ -110,7 +120,12 @@ public function getApcuKey($cid) {
+    if(function_exists('apcu_fetch')){

@@ -127,7 +142,13 @@ public function getMultiple(&$cids) {
+    if(function_exists('apcu_fetch')){

@@ -200,21 +221,36 @@ public function setMultiple(array $items = array()) {
+    if(function_exists('apcu_delete')){
...
+    if(function_exists('apcu_delete')){
...
+    if(function_exists('apcu_delete')){

@@ -228,7 +264,12 @@ public function garbageCollection() {
+    if(function_exists('apcu_inc')){

@@ -237,10 +278,23 @@ public function removeBin() {
+    if(function_exists('apcu_inc')){
...
+      if(function_exists('apcu_inc')){

+++ b/modules/supercache/src/Tests/Cache/ApcuRawBackendGeneralTestCaseTrait.php
@@ -14,7 +14,12 @@
+    if(function_exists('apc_uclear_cache')){

Better to move this checks to constructor to check only once

david_garcia’s picture

The good approach to this is writting the code to target APCu exclusively and then use this to ensure backwards compatibility:

https://packagist.org/packages/symfony/polyfill-apcu

Indeed, if someone writes a code that targets APCu and support for old APC is dropped, I would not mind commiting that breaking change. After all the old APC is dead.

  • david_garcia committed c1b8935 on 8.x-1.x
    Issue #2833414 by david_garcia_garcia: PHP 7 compatibility with apc
    
david_garcia’s picture

Category: Bug report » Task
Status: Needs work » Fixed

Approached and fixed using symfony's apcu pollyfill. Note that after this, if you are not using a build process for your Drupal 8 deployment, you should as the dependency is brought in through composer.json.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.