Skip to content
Permalink
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
  • Loading branch information
gadelkareem committed Jan 12, 2015
1 parent 81c0a6d commit e71030e89f4cd666742ae2ec39451782beb42f3a
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

@MattyLB

This comment has been minimized.

Copy link

@MattyLB MattyLB replied Jan 16, 2015

this fixed it for me. thank you!

@fisherwise

This comment has been minimized.

Copy link

@fisherwise fisherwise replied Nov 11, 2015

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

@younes0

This comment has been minimized.

Copy link

@younes0 younes0 replied Dec 6, 2015

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

@MattyLB

This comment has been minimized.

Copy link

@MattyLB MattyLB replied Dec 6, 2015

@MattyLB

This comment has been minimized.

Copy link

@MattyLB MattyLB replied Dec 6, 2015

@younes0

This comment has been minimized.

Copy link

@younes0 younes0 replied 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

This comment has been minimized.

Copy link

@MattyLB MattyLB replied Dec 6, 2015

@Tralapo

This comment has been minimized.

Copy link

@Tralapo Tralapo replied 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

This comment has been minimized.

Copy link

@younes0 younes0 replied Dec 6, 2015

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

@fisherwise

This comment has been minimized.

Copy link

@fisherwise fisherwise replied Dec 7, 2015

@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

This comment has been minimized.

Copy link

@MattyLB MattyLB replied Dec 7, 2015

@pratham2003

This comment has been minimized.

Copy link

@pratham2003 pratham2003 replied Dec 14, 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)
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.

@nemchik

This comment has been minimized.

Copy link

@nemchik nemchik replied Jan 13, 2016

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

This comment has been minimized.

Copy link

@kmob2 kmob2 replied 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!

@pratham2003

This comment has been minimized.

Copy link

@pratham2003 pratham2003 replied Jan 29, 2016

@kmob2
+1

@kmob2

This comment has been minimized.

Copy link

@kmob2 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?

@AviatorBobo

This comment has been minimized.

Copy link

@AviatorBobo AviatorBobo replied Mar 7, 2016

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

This comment has been minimized.

Copy link

@kmob2 kmob2 replied Mar 7, 2016

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

@alxander73

This comment has been minimized.

Copy link

@alxander73 alxander73 replied Mar 7, 2016

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

@flupkede

This comment has been minimized.

Copy link

@flupkede flupkede replied Mar 23, 2016

Thx Man,
This solved it for me to!

@c89williams

This comment has been minimized.

Copy link

@c89williams c89williams replied Apr 1, 2016

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

@kmob2

This comment has been minimized.

Copy link

@kmob2 kmob2 replied Apr 1, 2016

this is becoming a running gag

@natewoodbridge

This comment has been minimized.

Copy link

@natewoodbridge natewoodbridge replied Apr 18, 2016

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

@puccaso

This comment has been minimized.

Copy link

@puccaso puccaso replied Apr 19, 2016

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

This comment has been minimized.

Copy link

@gawry gawry replied Apr 24, 2016

@txaqo The fix in this commit fixes your problem.

@isigro

This comment has been minimized.

Copy link

@isigro isigro replied Apr 28, 2016

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

@a4jp-com

This comment has been minimized.

Copy link

@a4jp-com a4jp-com replied Apr 29, 2016

I hope this gets added quickly.

@pipdig

This comment has been minimized.

Copy link

@pipdig pipdig replied May 3, 2016

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

@zooks

This comment has been minimized.

Copy link

@zooks zooks replied Jun 10, 2016

Thanks, it works properly.

@Mike-Johnston

This comment has been minimized.

Copy link

@Mike-Johnston Mike-Johnston replied Jul 5, 2016

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

@cbratschi

This comment has been minimized.

Copy link

@cbratschi cbratschi replied Aug 8, 2016

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

This comment has been minimized.

@cbratschi

This comment has been minimized.

Copy link

@cbratschi cbratschi replied Aug 8, 2016

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

Please sign in to comment.
You can’t perform that action at this time.