Merge "Don't check namespace in SpecialWantedtemplates"
[lhc/web/wiklou.git] / includes / filebackend / SwiftFileBackend.php
index 6a0f2ee..408194f 100644 (file)
@@ -138,13 +138,12 @@ class SwiftFileBackend extends FileBackendStore {
                        if ( PHP_SAPI === 'cli' ) {
                                $this->srvCache = wfGetMainCache(); // preferrably memcached
                        } else {
-                               try { // look for APC, XCache, WinCache, ect...
-                                       $this->srvCache = ObjectCache::newAccelerator( array() );
-                               } catch ( Exception $e ) {
-                               }
+                               // look for APC, XCache, WinCache, ect...
+                               $this->srvCache = ObjectCache::newAccelerator( CACHE_NONE );
                        }
+               } else {
+                       $this->srvCache = new EmptyBagOStuff();
                }
-               $this->srvCache = $this->srvCache ?: new EmptyBagOStuff();
        }
 
        public function getFeatures() {
@@ -716,6 +715,11 @@ class SwiftFileBackend extends FileBackendStore {
                        return $objHdrs; // failed
                }
 
+               // Find prior custom HTTP headers
+               $postHeaders = $this->getCustomHeaders( $objHdrs );
+               // Find prior metadata headers
+               $postHeaders += $this->getMetadataHeaders( $objHdrs );
+
                $status = Status::newGood();
                /** @noinspection PhpUnusedLocalVariableInspection */
                $scopeLockS = $this->getScopedFileLocks( array( $path ), LockManager::LOCK_UW, $status );
@@ -725,11 +729,13 @@ class SwiftFileBackend extends FileBackendStore {
                                $hash = $tmpFile->getSha1Base36();
                                if ( $hash !== false ) {
                                        $objHdrs['x-object-meta-sha1base36'] = $hash;
+                                       // Merge new SHA1 header into the old ones
+                                       $postHeaders['x-object-meta-sha1base36'] = $hash;
                                        list( $srcCont, $srcRel ) = $this->resolveStoragePathReal( $path );
-                                       list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->http->run( array(
+                                       list( $rcode ) = $this->http->run( array(
                                                'method' => 'POST',
                                                'url' => $this->storageUrl( $auth, $srcCont, $srcRel ),
-                                               'headers' => $this->authTokenHeaders( $auth ) + $objHdrs
+                                               'headers' => $this->authTokenHeaders( $auth ) + $postHeaders
                                        ) );
                                        if ( $rcode >= 200 && $rcode <= 299 ) {
                                                $this->deleteFileCache( $path );