Fixing Warning on HHVM #1

Open
wants to merge 1 commit into
from

Projects

None yet
@gadelkareem

\nWarning: Parameter 1 to W3_Plugin_TotalCache::ob_callback() expected to be a reference, value given in /wp-includes/functions.php on line 3269

@gadelkareem gadelkareem Fixing Warning on HHVM
\nWarning: Parameter 1 to W3_Plugin_TotalCache::ob_callback() expected to be a reference, value given in /wp-includes/functions.php on line 3269
e71030e
@MattyLB

this fixed it for me. thank you!

This is still in the newest version!
v 0.9.4.1 from wordpress.org

@mikaoras how can the plugin author miss this one? this ridiculous bug prevents php7 migration

@MattyLB I see, so which plugin that enables object/page cache do you suggest ?
While PHP7 dramatically increases performance, Page Caching is still very useful.
And Varnish is way more complicated to setup than W3TC

Found this with Google, it indeed fixes this plugin in PHP 7. Maybe the devs didn't see it? The repo does mention: "Unofficial mirror repository; no pull requests, please."

Sent them an email today, will see what they have to say. For now: thanks @gadelkareem!

@Tralapo there's an issue about PHP7 in their support forum and PHP7 RCs are out since months now :(

@younes0 php7 really sent A LOT OF RCs
and put out the stable version in a hurry
can't imagine is there still some problems in current version

Its starting to get annoying that I have to update the /w3-total-cache/lib/W3/Plugin/TotalCache.php file and replace
function ob_callback(&$buffer)
with
function ob_callback($buffer)
every time there is an update across multiple sites which are running on hhvm.

Going to create a sed or diff-patch script now.

-Update-
Command to replace function ob_callback(&$buffer) with function ob_callback($buffer)
sed -i.bak 's/function ob_callback(&/function ob_callback(/g' /path/to/public_html/wp-content/plugins/w3-total-cache/lib/W3/Plugin/TotalCache.php

You can skip the -i.bak option to prevent a backup file from being created.

Just by some quick googling it seems the & was added for hhvm compatibility. Maybe some kind of pull request could be made to the main project that would detect if hhvm is being used and then keep the & but otherwise not use it...?

looking at the code i think this might mean duplicating the function, but really i don't know.

There has been no update of w3tc in over 5 months and PHP7 and WordPress support for PHP7 have both been out for over 3 months.
It's about time that this gets fixed!

kmob2 replied Mar 4, 2016

I can't believe that such a widespread issue has still not been fixed after 7 months.
It literally takes 1 change of 1 character to fix this. What could the possible excuse be for not updating W3-Total cache plugin with this fix?

Just had the same problem on xx And again I fixed it, with the solution provided above.. Thanks a million... :) What I dont understand is, why doesnt this happen on all of my other sites? And why does it happen in the first place?

kmob2 replied Mar 7, 2016

@AviatorBobo It's a problem that occurs on web server using PHP 7

Many Thanks!
Jus now with PHP 7.0. I have this problem and I solve it Thanks you!

Thx Man,
This solved it for me to!

Why is this still an issue? W3TC could totally detect if PHP 7 is being used and define the function differently.

kmob2 replied Apr 1, 2016

this is becoming a running gag

I also had simular problems with php 7.0. Would be great to have a fix as soon as possible

txaqo replied Apr 19, 2016 edited

hi guys

i am having a similar issue,
but with line 3553 of the functions.php file..

latest hhvm,
and php7..

/**

  • Flush all output buffers for PHP 5.2.
    *
  • Make sure all output buffers are flushed before our singletons are destroyed.
    *
  • @since 2.2.0
    */

function wp_ob_end_flush_all() {

    $levels = ob_get_level();


    for ($i=0; $i<$levels; $i++)


            ob_end_flush();                       <<<<< 3553

}

/**

any quick fix for this?

@txaqo The fix in this commit fixes your problem.

I am running php7 and have same issue, the solution works for me, thanks...

I hope this gets added quickly.

Wow, this really goes to show how un-maintained this plugin is. Time to switch!

rpre replied Jun 10, 2016

Thanks, it works properly.

Can confirm this fixed php7 problems for this plugin with my site. CDN and Cache options now work correctly.

cbratschi replied Aug 8, 2016 edited

A PHP production system was suddenly broken today. I applied this fix before but it is no longer working with the latest PHP 7 version! On PHP 7.0.9 I was just getting a white page and even the dashboard could no longer be accessed. Adding the ampersand again fixed this problem but there are secondary issues still there. So we need a real fix which solves the root cause.

@Mike-Johnston Thanks, found this in the meantime too.

Here are all occurrences of ob_callback() which have to be modified:

https://github.com/crowdfavorite-mirrors/wp-w3-total-cache/search?utf8=%E2%9C%93&q=ob_callback

Attention: PgCache.php is in the parent folder. All other files are in the same directory.

@alltry
alltry commented Sep 28, 2015

Thank you, solved to me too!

@Danw33
Danw33 commented Dec 14, 2015

@gadelkareem Thanks for this! Seems to have sorted our issue with HHVM and W3 Total Cache.

Hopefully someone can get the developers to finally add this to the "next release" as they have promised since 2014.

@mef
mef commented Dec 16, 2015

l also would like this bug to be fixed. This pull request is not likely to help much though, cf. repository description:

Unofficial mirror repository; no pull requests, please.

@josflachs

I got this problem on Saturday (29-04-2016) after installing the plugin. This fix did make the waring disappear, but also most of the web content...

@LucianoBellacci

I still have the problem on my site luciano-bellacci.dk and company site Waimea.dk. It seems that the plugin is updated to the newest version..

@hilevelgit
hilevelgit commented Aug 24, 2016 edited

Replacing function ob_callback(&$buffer) with function ob_callback($buffer) gives me a white page of death on php7 any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment