From 611ae607a0da884358a2704ed8bb1abdf92c0154 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 20 Nov 2012 18:16:15 -0800 Subject: [PATCH] Fixed metadata-loss bug from b80bd6159bdf946c1d4fa1e143fea221937d848a. * Contrary to Swift docs, doing a POST seems to kill all the old metadata headers. I noticed this in testing due to addMissingMetadata() notices. Change-Id: I988d7a8d38569823c9d66605b02705ee15a8bbe7 --- includes/filebackend/SwiftFileBackend.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/includes/filebackend/SwiftFileBackend.php b/includes/filebackend/SwiftFileBackend.php index 6a27e9bff4..5a9b062d9a 100644 --- a/includes/filebackend/SwiftFileBackend.php +++ b/includes/filebackend/SwiftFileBackend.php @@ -583,9 +583,11 @@ class SwiftFileBackend extends FileBackendStore { try { $sContObj = $this->getContainer( $srcCont ); - $srcObj = new CF_Object( $sContObj, $srcRel, false, false ); // skip HEAD - // Merge in the new metadata and header values... - $srcObj->headers = $hdrs; + // Get the latest version of the current metadata + $srcObj = $sContObj->get_object( $srcRel, + $this->headersFromParams( array( 'latest' => true ) ) ); + // Merge in the metadata updates... + $srcObj->headers = $hdrs + $srcObj->headers; $srcObj->sync_metadata(); // save to Swift $this->purgeCDNCache( array( $srcObj ) ); } catch ( CDNNotEnabledException $e ) { @@ -816,6 +818,7 @@ class SwiftFileBackend extends FileBackendStore { } } } + trigger_error( "Unable to set SHA-1 metadata for $path", E_USER_WARNING ); $obj->setMetadataValues( array( 'Sha1base36' => false ) ); wfProfileOut( __METHOD__ ); return false; // failed -- 2.20.1