Resolved: [hphp] Warning: Parameter 1 to W3_Plugin_TotalCache::ob_callback() expected to be a reference, value given in /wp-includes/functions.php on line 3282
Resolved: [hphp] Warning: Parameter 1 to W3_Plugin_TotalCache::ob_callback() expected to be a reference, value given in /wp-includes/functions.php on line 3282
As you probably know (otherwise you would probably not be here), after deciding to move form PHP to HHVM, if you are running a WordPress site and use W3 Total Cache you will encounter an endless number of errors all revolving ob_callback() expecting a reference:
[Sun May 17 18:41:51 2015] [hphp] [14300:7ff40dfff700:39:000001] [] \nWarning: Parameter 1 to W3_Plugin_TotalCache::ob_callback() expected to be a reference, value given in /wp-includes/functions.php on line 3282
I have good and bad news for you. The good news is that there is a fix for this (yay!) The bad news is that next time you update or re-install W3 Total Cache you might or will need to perform this fix again. I know, it is a pain but thus far this is the best answer I could find (or rather, the only one).
So basically what we are going to do is fix some W3 Total Cache php code so that this warning does not show again. I recommend you back up your system just in case something goes wrong; and by system I think just your plugins directory or the file we are going to modify should suffice.
The file we need to modify is located here (relatively speaking, change /var/www/ for your site’s actual www root):
/var/www/wp-content/plugins/w3-total-cache/lib/W3/Plugin/TotalCache.php
Now, one you have opened the file on your favorite text editor (say nano), look for the following line (for me it is on line 512):
function ob_callback(&$buffer) {
The key here is to change the parameter to just $buffer, like so:
function ob_callback($buffer) {
This should take care of the issue. If you look at the error log (/var/log/hhvm/error.log) you’ll notice. In my case I had several messages per second so with tail -f /var/log/hhvm/error.log you can tell it is working. Hope this worked for you too!
Yeah,,,,Thhis worked for me. Thanks 😀
Nice to hear it is of use to others. yw
Thanks for sharing this. I was having the same issue. This saved some time.
Regards
Glad to hear that
Perfect! One other discussion made it sound like it hadn’t yet (as of December 2015) been made fully compatible with PHP7… Seems the issue hasn’t yet been patched for good…