Merge "[FileBackend] Bumped Swift auth caching TTL."
[lhc/web/wiklou.git] / includes / filebackend / SwiftFileBackend.php
index e84f854..960d71c 100644 (file)
@@ -111,7 +111,7 @@ class SwiftFileBackend extends FileBackendStore {
                        : false;
                $this->swiftCDNExpiry = isset( $config['swiftCDNExpiry'] )
                        ? $config['swiftCDNExpiry']
-                       : 3600; // hour
+                       : 12*3600; // 12 hours is safe (tokens last 24 hours per http://docs.openstack.org)
                $this->swiftCDNPurgable = isset( $config['swiftCDNPurgable'] )
                        ? $config['swiftCDNPurgable']
                        : true;
@@ -729,6 +729,7 @@ class SwiftFileBackend extends FileBackendStore {
                if ( isset( $obj->metadata['Sha1base36'] ) ) {
                        return true; // nothing to do
                }
+               wfProfileIn( __METHOD__ );
                $status = Status::newGood();
                $scopeLockS = $this->getScopedFileLocks( array( $path ), LockManager::LOCK_UW, $status );
                if ( $status->isOK() ) {
@@ -739,11 +740,13 @@ class SwiftFileBackend extends FileBackendStore {
                                if ( $hash !== false ) {
                                        $obj->metadata['Sha1base36'] = $hash;
                                        $obj->sync_metadata(); // save to Swift
+                                       wfProfileOut( __METHOD__ );
                                        return true; // success
                                }
                        }
                }
                $obj->metadata['Sha1base36'] = false;
+               wfProfileOut( __METHOD__ );
                return false; // failed
        }
 
@@ -849,13 +852,13 @@ class SwiftFileBackend extends FileBackendStore {
                                                // See function "create_container_table" in common/db.py.
                                                // If a directory is not "greater" than the last one,
                                                // then it was already listed by the calling iterator.
-                                               if ( $objectDir > $lastDir ) {
+                                               if ( strcmp( $objectDir, $lastDir ) > 0 ) {
                                                        $pDir = $objectDir;
                                                        do { // add dir and all its parent dirs
                                                                $dirs[] = "{$pDir}/";
                                                                $pDir = $this->getParentDir( $pDir );
                                                        } while ( $pDir !== false // sanity
-                                                               && $pDir > $lastDir // not done already
+                                                               && strcmp( $pDir, $lastDir ) > 0 // not done already
                                                                && strlen( $pDir ) > strlen( $dir ) // within $dir
                                                        );
                                                }