Currently Viewing Posts Tagged W3TC

Small PHP 7.2 Compatibility Bug of W3 Total Cache

When I upgrade my php to php 7.2, I saw a lot of error log in the log file.

[error] 1502#1502: *625 FastCGI sent in stderr: “PHP message: PHP Warning: count(): Parameter must be an array or an object that implements Countable in /<purged>/wp-content/plugins/w3-total-cache/Cdn_Plugin.php on line 1203” while reading response header from upstream, client: 135.0.172.188, server: www.yinfor.com, request: “GET / HTTP/2.0”, upstream: “fastcgi://unix:/var/run/php/php7.2-fpm.sock:”, host: “www.yinfor.com”

 

It is a bug or error, or just a compatibility issue between php 7.2 and W3 Total Cache.

Based on the the dissus on the WP site, TeroSalminen has a workaround.

Replacing a line in “function get_replaced_urls()” seems to work:

Replace the line
if ( count( $this->_replaced_urls ) ) {
with
if ( $this->_replaced_urls && count($this->_replaced_urls) ) {
and test.

Fix the error: Parameter 1 to W3_Plugin_TotalCache::ob_callback() expected to be a reference,

I checked my Nginx log files and saw a lot of errors as below:

*11047 FastCGI sent in stderr: “PHP message: PHP Warning: Parameter 1 to W3_Plugin_TotalCache::ob_callback() expected to be a reference, value given in /home/users/yinfor.com/wp-includes/functions.php on line 3597” while reading response header from upstream,

I googled it and found the answer.

The reason why it happened is PHP 7 and W3 Total Cache.

Since I can not change PHP 7, I have to change something in W3 Total Cache plugin.

  1.  Find the file /wp-content/plugins/w3-total-cache/lib/W3/Plugin/TotalCache.php
  2.  Go to line 512, and replace following
    function ob_callback(&$buffer)
    with
    function ob_callback($buffer)
  3.  Save it.

 

Do you still need Xcache when you have PHP Opcache

This VPS is running with PHP 5.4.25.  Zend OPcache is a built-in module in PHP 5.4.25.

I have Xcache installed before. Today, I removed it and just use OPcache.

When I use Xcache and Opcache at the same time. And config Database cache and object cache to use opcode:Xcache. I found the Xcache doesn’t help me a lot. See screenshot below.

xcache

PHP scripts are not cached in Xcache entirely.  I thought Zend OPcache is working on php scripts.

Continue reading “Do you still need Xcache when you have PHP Opcache”

  • Archives