Skip to content

Commit

Permalink
Fixing Warning on HHVM
Browse files Browse the repository at this point in the history
\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 e71030e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/W3/Plugin/TotalCache.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ function footer() {
* @param string $buffer * @param string $buffer
* @return string * @return string
*/ */
function ob_callback(&$buffer) { function ob_callback($buffer) {
global $wpdb; global $wpdb;


if ($buffer != '') { if ($buffer != '') {
Expand Down

33 comments on commit e71030e

@MattyLB
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fixed it for me. thank you!

@mylylyl
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@younes0
Copy link

@younes0 younes0 commented on e71030e Dec 6, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@MattyLB
Copy link

@MattyLB MattyLB commented on e71030e Dec 6, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MattyLB
Copy link

@MattyLB MattyLB commented on e71030e Dec 6, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@younes0
Copy link

@younes0 younes0 commented on e71030e Dec 6, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link

@MattyLB MattyLB commented on e71030e Dec 6, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tralapo
Copy link

@Tralapo Tralapo commented on e71030e Dec 6, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

@younes0 younes0 commented on e71030e Dec 6, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@mylylyl
Copy link

@mylylyl mylylyl commented on e71030e Dec 7, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link

@MattyLB MattyLB commented on e71030e Dec 7, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pratham2003
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

@kmob2 kmob2 commented on e71030e Jan 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kmob2
+1

@kmob2
Copy link

@kmob2 kmob2 commented on e71030e Mar 4, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

@kmob2 kmob2 commented on e71030e Mar 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@alxander73
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@flupkede
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx Man,
This solved it for me to!

@c89williams
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@kmob2
Copy link

@kmob2 kmob2 commented on e71030e Apr 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is becoming a running gag

@natewoodbridge
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@puccaso
Copy link

@puccaso puccaso commented on e71030e Apr 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

@gawry gawry commented on e71030e Apr 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@txaqo The fix in this commit fixes your problem.

@isigro
Copy link

@isigro isigro commented on e71030e Apr 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@a4jp-com
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope this gets added quickly.

@pipdig
Copy link

@pipdig pipdig commented on e71030e May 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@zooks
Copy link

@zooks zooks commented on e71030e Jun 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, it works properly.

@Mike-Johnston
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@cbratschi
Copy link

@cbratschi cbratschi commented on e71030e Aug 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cbratschi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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