Browse files

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
1 parent 81c0a6d commit e71030e89f4cd666742ae2ec39451782beb42f3a @gadelkareem committed Jan 12, 2015
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/W3/Plugin/TotalCache.php
@@ -509,7 +509,7 @@ function footer() {
* @param string $buffer
* @return string
- function ob_callback(&$buffer) {
+ function ob_callback($buffer) {
global $wpdb;
if ($buffer != '') {

33 comments on commit e71030e


this fixed it for me. thank you!


This is still in the newest version!
v from

younes0 commented on e71030e Dec 6, 2015

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

MattyLB commented on e71030e Dec 6, 2015
MattyLB commented on e71030e Dec 6, 2015
younes0 commented on e71030e Dec 6, 2015

@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

MattyLB commented on e71030e Dec 6, 2015
Tralapo commented on e71030e Dec 6, 2015

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!

younes0 commented on e71030e Dec 6, 2015

@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

MattyLB commented on e71030e Dec 7, 2015

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)
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.

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.

kmob2 commented on e71030e Jan 29, 2016

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 commented on e71030e 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 commented on e71030e 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 commented on e71030e 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 commented on e71030e 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?

gawry commented on e71030e Apr 24, 2016

@txaqo The fix in this commit fixes your problem.

isigro commented on e71030e Apr 28, 2016

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


I hope this gets added quickly.

pipdig commented on e71030e May 3, 2016

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

rpre commented on e71030e 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 commented on e71030e 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:

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

Please sign in to comment.