bug 36087: PostgresUpdater fails on 8.3.14
[lhc/web/wiklou.git] / includes / SquidPurgeClient.php
index 65da5c1..b0418ba 100644 (file)
@@ -33,6 +33,8 @@ class SquidPurgeClient {
        /**
         * Open a socket if there isn't one open already, return it.
         * Returns false on error.
+        *
+        * @return bool|resource
         */
        protected function getSocket() {
                if ( $this->socket !== null ) {
@@ -64,6 +66,7 @@ class SquidPurgeClient {
 
        /**
         * Get read socket array for select()
+        * @return array
         */
        public function getReadSocketsForSelect() {
                if ( $this->readState == 'idle' ) {
@@ -78,6 +81,7 @@ class SquidPurgeClient {
 
        /**
         * Get write socket array for select()
+        * @return array
         */
        public function getWriteSocketsForSelect() {
                if ( !strlen( $this->writeBuffer ) ) {
@@ -139,9 +143,11 @@ class SquidPurgeClient {
 
        /**
         * Queue a purge operation
+        *
+        * @param $url string
         */
        public function queuePurge( $url ) {
-               $url = str_replace( "\n", '', $url );
+               $url = SquidUpdate::expand( str_replace( "\n", '', $url ) );
                $this->requests[] = "PURGE $url HTTP/1.0\r\n" .
                        "Connection: Keep-Alive\r\n" .
                        "Proxy-Connection: Keep-Alive\r\n" .
@@ -151,6 +157,9 @@ class SquidPurgeClient {
                }
        }
 
+       /**
+        * @return bool
+        */
        public function isIdle() {
                return strlen( $this->writeBuffer ) == 0 && $this->readState == 'idle';
        }
@@ -220,6 +229,10 @@ class SquidPurgeClient {
                while ( $this->socket && $this->processReadBuffer() === 'continue' );
        }
 
+       /**
+        * @throws MWException
+        * @return string
+        */
        protected function processReadBuffer() {
                switch ( $this->readState ) {
                case 'idle':
@@ -259,13 +272,17 @@ class SquidPurgeClient {
                }
        }
 
+       /**
+        * @param $line
+        * @return
+        */
        protected function processStatusLine( $line ) {
                if ( !preg_match( '!^HTTP/(\d+)\.(\d+) (\d{3}) (.*)$!', $line, $m ) ) {
                        $this->log( 'invalid status line' );
                        $this->markDown();
                        return;
                }
-               list( $all, $major, $minor, $status, $reason ) = $m;
+               list( , , , $status, $reason ) = $m;
                $status = intval( $status );
                if ( $status !== 200 && $status !== 404 ) {
                        $this->log( "unexpected status code: $status $reason" );
@@ -275,6 +292,9 @@ class SquidPurgeClient {
                $this->readState = 'header';
        }
 
+       /**
+        * @param $line string
+        */
        protected function processHeaderLine( $line ) {
                if ( preg_match( '/^Content-Length: (\d+)$/i', $line, $m ) ) {
                        $this->bodyRemaining = intval( $m[1] );
@@ -305,6 +325,10 @@ class SquidPurgeClient {
 }
 
 class SquidPurgeClientPool {
+
+       /**
+        * @var array of SquidPurgeClient
+        */
        var $clients = array();
        var $timeout = 5;
 
@@ -314,6 +338,10 @@ class SquidPurgeClientPool {
                }
        }
 
+       /**
+        * @param $client SquidPurgeClient
+        * @return void
+        */
        public function addClient( $client ) {
                $this->clients[] = $client;
        }
@@ -356,12 +384,12 @@ class SquidPurgeClientPool {
                        }
 
                        foreach ( $readSockets as $key => $socket ) {
-                               list( $clientIndex, $i ) = explode( '/', $key );
+                               list( $clientIndex, ) = explode( '/', $key );
                                $client = $this->clients[$clientIndex];
                                $client->doReads();
                        }
                        foreach ( $writeSockets as $key => $socket ) {
-                               list( $clientIndex, $i ) = explode( '/', $key );
+                               list( $clientIndex, ) = explode( '/', $key );
                                $client = $this->clients[$clientIndex];
                                $client->doWrites();
                        }