WordPress Varnish plugin error

Was looking for a way to purge Varnish cache when pages are updated or added. WordPress Varnish plugin looks exactly like what I'm after, except it threw up some errors out of the box.

Errors:

Warning: fsockopen() expects parameter 2 to be long, string given in /path/to/wordpress-varnish/wp-varnish.php on line 138
()

and

Warning: fsockopen() expects parameter 2 to be long, string given in /path/to/wordpress-varnish/wp-varnish.php on line 115
()

My hack to fix the errors and also to add MU blogs to list of common URLs to purge on changes:

diff -up wp-varnish.php.default wp-varnish.php
--- wp-varnish.php.default	2010-05-10 17:20:25.000000000 -0700
+++ wp-varnish.php	2010-05-10 21:10:05.000000000 -0700
@@ -54,6 +54,13 @@ class WPVarnish {
     $this->WPVarnishPurgeObject("/");
     $this->WPVarnishPurgeObject("/feed/");
     $this->WPVarnishPurgeObject("/feed/atom/");
+    $this->WPVarnishPurgeObject("/alain/");
+    $this->WPVarnishPurgeObject("/alain/feed/");
+    $this->WPVarnishPurgeObject("/alain/feed/atom/");
+    $this->WPVarnishPurgeObject("/jason/");
+    $this->WPVarnishPurgeObject("/jason/feed/");
+    $this->WPVarnishPurgeObject("/jason/feed/atom/");
+
   }
 
   function WPVarnishAdminMenu() {
@@ -112,7 +119,7 @@ class WPVarnish {
     $wpv_host = preg_replace($wpv_replace_wpurl, "", $wpv_wpurl);
 
     for ($i = 0; $i < count ($wpv_purgeaddr); $i++) {
-      $varnish_sock = fsockopen($wpv_purgeaddr[$i], $wpv_purgeport[$i], $errno, $errstr, 30);
+      $varnish_sock = fsockopen("127.0.0.1", "80", $errno, $errstr, 30);
       if (!$varnish_sock) {
         echo "$errstr ($errno)
\n"; } else { @@ -135,7 +142,7 @@ class WPVarnish { $wpv_host = preg_replace($wpv_replace_wpurl, "", $wpv_wpurl); for ($i = 0; $i < count ($wpv_purgeaddr); $i++) { - $varnish_sock = fsockopen($wpv_purgeaddr[$i], $wpv_purgeport[$i], $errno, $errstr, 30); + $varnish_sock = fsockopen("127.0.0.1", "80", $errno, $errstr, 30); if (!$varnish_sock) { echo "$errstr ($errno)
\n"; } else {

Leave a comment

NOTE: Enclose quotes in <blockquote></blockquote>. Enclose code in <pre lang="LANG"></pre> (where LANG is one of these).