X-Git-Url: https://git.cyclocoop.org/%242?a=blobdiff_plain;f=includes%2Ffilerepo%2Fbackend%2FSwiftFileBackend.php;h=08a311933777ab9b47d9855eea9be1bbd56d314a;hb=1abcd5e30eea04bb03f01eb84f9c77bca7980729;hp=1eb8a34b0ae1f61a3093bdfaa4eb0be71612c1ee;hpb=6e96a6e8e616943f477e571d0dd0f1cfb66c47e4;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/filerepo/backend/SwiftFileBackend.php b/includes/filerepo/backend/SwiftFileBackend.php index 1eb8a34b0a..08a3119337 100644 --- a/includes/filerepo/backend/SwiftFileBackend.php +++ b/includes/filerepo/backend/SwiftFileBackend.php @@ -47,6 +47,7 @@ class SwiftFileBackend extends FileBackendStore { protected $conn; // Swift connection handle protected $connStarted = 0; // integer UNIX timestamp protected $connContainers = array(); // container object cache + protected $connException; // CloudFiles exception /** * @see FileBackendStore::__construct() @@ -966,11 +967,11 @@ class SwiftFileBackend extends FileBackendStore { * Get a connection to the Swift proxy * * @return CF_Connection|bool False on failure - * @throws InvalidResponseException + * @throws CloudFilesException */ protected function getConnection() { - if ( $this->conn === false ) { - throw new InvalidResponseException; // failed last attempt + if ( $this->connException instanceof Exception ) { + throw $this->connException; // failed last attempt } // Session keys expire after a while, so we renew them periodically if ( $this->conn && ( time() - $this->connStarted ) > $this->authTTL ) { @@ -978,21 +979,18 @@ class SwiftFileBackend extends FileBackendStore { $this->conn = null; } // Authenticate with proxy and get a session key... - if ( $this->conn === null ) { + if ( !$this->conn ) { + $this->connStarted = 0; $this->connContainers = array(); try { $this->auth->authenticate(); $this->conn = new CF_Connection( $this->auth ); $this->connStarted = time(); - } catch ( AuthenticationException $e ) { - $this->conn = false; // don't keep re-trying - } catch ( InvalidResponseException $e ) { - $this->conn = false; // don't keep re-trying + } catch ( CloudFilesException $e ) { + $this->connException = $e; // don't keep re-trying + throw $e; // throw it back } } - if ( !$this->conn ) { - throw new InvalidResponseException; // auth/connection problem - } return $this->conn; } @@ -1010,8 +1008,7 @@ class SwiftFileBackend extends FileBackendStore { * @param $container string Container name * @param $bypassCache bool Bypass all caches and load from Swift * @return CF_Container - * @throws NoSuchContainerException - * @throws InvalidResponseException + * @throws CloudFilesException */ protected function getContainer( $container, $bypassCache = false ) { $conn = $this->getConnection(); // Swift proxy connection