Updated some try-catch statements: MWException -> Exception
[lhc/web/wiklou.git] / includes / filebackend / SwiftFileBackend.php
index 625b9b4..2637b5a 100644 (file)
@@ -537,6 +537,7 @@ class SwiftFileBackend extends FileBackendStore {
                        return $status; // already there
                } elseif ( $stat === null ) {
                        $status->fatal( 'backend-fail-internal', $this->name );
+                       wfDebugLog( 'SwiftBackend', __METHOD__ . ': cannot get container stat' );
 
                        return $status;
                }
@@ -568,6 +569,7 @@ class SwiftFileBackend extends FileBackendStore {
                        $status->fatal( 'backend-fail-usable', $params['dir'] );
                } else {
                        $status->fatal( 'backend-fail-internal', $this->name );
+                       wfDebugLog( 'SwiftBackend', __METHOD__ . ': cannot get container stat' );
                }
 
                return $status;
@@ -588,6 +590,7 @@ class SwiftFileBackend extends FileBackendStore {
                        $status->fatal( 'backend-fail-usable', $params['dir'] );
                } else {
                        $status->fatal( 'backend-fail-internal', $this->name );
+                       wfDebugLog( 'SwiftBackend', __METHOD__ . ': cannot get container stat' );
                }
 
                return $status;
@@ -607,6 +610,7 @@ class SwiftFileBackend extends FileBackendStore {
                        return $status; // ok, nothing to do
                } elseif ( !is_array( $stat ) ) {
                        $status->fatal( 'backend-fail-internal', $this->name );
+                       wfDebugLog( 'SwiftBackend', __METHOD__ . ': cannot get container stat' );
 
                        return $status;
                }
@@ -643,7 +647,7 @@ class SwiftFileBackend extends FileBackendStore {
                        $timestamp = new MWTimestamp( $ts );
 
                        return $timestamp->getTimestamp( $format );
-               } catch ( MWException $e ) {
+               } catch ( Exception $e ) {
                        throw new FileBackendError( $e->getMessage() );
                }
        }
@@ -660,7 +664,7 @@ class SwiftFileBackend extends FileBackendStore {
                        return $objHdrs; // nothing to do
                }
 
-               $section = new ProfileSection( __METHOD__ . '-' . $this->name );
+               $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
                trigger_error( "$path was not stored with SHA-1 metadata.", E_USER_WARNING );
 
                $auth = $this->getAuthentication();
@@ -794,7 +798,7 @@ class SwiftFileBackend extends FileBackendStore {
                        return $dirs; // nothing more
                }
 
-               $section = new ProfileSection( __METHOD__ . '-' . $this->name );
+               $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
 
                $prefix = ( $dir == '' ) ? null : "{$dir}/";
                // Non-recursive: only list dirs right under $dir
@@ -874,7 +878,7 @@ class SwiftFileBackend extends FileBackendStore {
                        return $files; // nothing more
                }
 
-               $section = new ProfileSection( __METHOD__ . '-' . $this->name );
+               $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
 
                $prefix = ( $dir == '' ) ? null : "{$dir}/";
                // $objects will contain a list of unfiltered names or CF_Object items
@@ -1253,6 +1257,7 @@ class SwiftFileBackend extends FileBackendStore {
 
                if ( $rcode != 204 && $rcode !== 202 ) {
                        $status->fatal( 'backend-fail-internal', $this->name );
+                       wfDebugLog( 'SwiftBackend', __METHOD__ . ': unexpected rcode value (' . $rcode . ')' );
                }
 
                return $status;
@@ -1267,7 +1272,7 @@ class SwiftFileBackend extends FileBackendStore {
         * @return array|bool|null False on 404, null on failure
         */
        protected function getContainerStat( $container, $bypassCache = false ) {
-               $section = new ProfileSection( __METHOD__ . '-' . $this->name );
+               $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
 
                if ( $bypassCache ) { // purge cache
                        $this->containerStatCache->clear( $container );
@@ -1280,13 +1285,11 @@ class SwiftFileBackend extends FileBackendStore {
                                return null;
                        }
 
-                       wfProfileIn( __METHOD__ . "-{$this->name}-miss" );
                        list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->http->run( array(
                                'method' => 'HEAD',
                                'url' => $this->storageUrl( $auth, $container ),
                                'headers' => $this->authTokenHeaders( $auth )
                        ) );
-                       wfProfileOut( __METHOD__ . "-{$this->name}-miss" );
 
                        if ( $rcode === 204 ) {
                                $stat = array(