From d4902a82dbec595e28f482fa4fcdccb8204066bf Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Fri, 22 Nov 2013 21:28:20 +0100 Subject: [PATCH] Update formatting of externalstore classes Change-Id: Ie31c370ba497eedc7458973b704132cf4725cf1f --- includes/externalstore/ExternalStore.php | 2 ++ includes/externalstore/ExternalStoreDB.php | 13 ++++++++++++- includes/externalstore/ExternalStoreMedium.php | 1 + includes/externalstore/ExternalStoreMwstore.php | 3 +++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/includes/externalstore/ExternalStore.php b/includes/externalstore/ExternalStore.php index 462b0b900b..9e9d976de7 100644 --- a/includes/externalstore/ExternalStore.php +++ b/includes/externalstore/ExternalStore.php @@ -59,6 +59,7 @@ class ExternalStore { } $class = 'ExternalStore' . ucfirst( $proto ); + // Any custom modules should be added to $wgAutoLoadClasses for on-demand loading return class_exists( $class ) ? new $class( $params ) : false; } @@ -120,6 +121,7 @@ class ExternalStore { $retval[$url] = false; } } + return $retval; } diff --git a/includes/externalstore/ExternalStoreDB.php b/includes/externalstore/ExternalStoreDB.php index 46a89379a7..8c2147aaf1 100644 --- a/includes/externalstore/ExternalStoreDB.php +++ b/includes/externalstore/ExternalStoreDB.php @@ -42,6 +42,7 @@ class ExternalStoreDB extends ExternalStoreMedium { if ( $itemID !== false && $ret !== false ) { return $ret->getItem( $itemID ); } + return $ret; } @@ -66,6 +67,7 @@ class ExternalStoreDB extends ExternalStoreMedium { $ret = array(); foreach ( $batched as $cluster => $batchByCluster ) { $res = $this->batchFetchBlobs( $cluster, $batchByCluster ); + /** @var HistoryBlob $blob */ foreach ( $res as $id => $blob ) { foreach ( $batchByCluster[$id] as $itemID ) { $url = $inverseUrlMap[$cluster][$id][$itemID]; @@ -77,6 +79,7 @@ class ExternalStoreDB extends ExternalStoreMedium { } } } + return $ret; } @@ -96,6 +99,7 @@ class ExternalStoreDB extends ExternalStoreMedium { if ( $dbw->getFlag( DBO_TRX ) ) { $dbw->commit( __METHOD__ ); } + return "DB://$cluster/$id"; } @@ -142,6 +146,7 @@ class ExternalStoreDB extends ExternalStoreMedium { function &getMaster( $cluster ) { $wiki = isset( $this->params['wiki'] ) ? $this->params['wiki'] : false; $lb =& $this->getLoadBalancer( $cluster ); + return $lb->getConnection( DB_MASTER, array(), $wiki ); } @@ -156,6 +161,7 @@ class ExternalStoreDB extends ExternalStoreMedium { if ( is_null( $table ) ) { $table = 'blobs'; } + return $table; } @@ -182,6 +188,7 @@ class ExternalStoreDB extends ExternalStoreMedium { if ( isset( $externalBlobCache[$cacheID] ) ) { wfDebugLog( 'ExternalStoreDB-cache', "ExternalStoreDB::fetchBlob cache hit on $cacheID\n" ); + return $externalBlobCache[$cacheID]; } @@ -209,6 +216,7 @@ class ExternalStoreDB extends ExternalStoreMedium { } $externalBlobCache = array( $cacheID => &$ret ); + return $ret; } @@ -217,7 +225,8 @@ class ExternalStoreDB extends ExternalStoreMedium { * * @param string $cluster A cluster name valid for use with LBFactory * @param array $ids A map from the blob_id's to look for to the requested itemIDs in the blobs - * @return array A map from the blob_id's requested to their content. Unlocated ids are not represented + * @return array A map from the blob_id's requested to their content. + * Unlocated ids are not represented */ function batchFetchBlobs( $cluster, array $ids ) { $dbr = $this->getSlave( $cluster ); @@ -248,6 +257,7 @@ class ExternalStoreDB extends ExternalStoreMedium { " master on '$cluster' failed locating items: " . implode( ',', array_keys( $ids ) ) . "\n" ); } + return $ret; } @@ -274,6 +284,7 @@ class ExternalStoreDB extends ExternalStoreMedium { protected function parseURL( $url ) { $path = explode( '/', $url ); + return array( $path[2], // cluster $path[3], // id diff --git a/includes/externalstore/ExternalStoreMedium.php b/includes/externalstore/ExternalStoreMedium.php index 6ab1f8c2ba..a526df609c 100644 --- a/includes/externalstore/ExternalStoreMedium.php +++ b/includes/externalstore/ExternalStoreMedium.php @@ -64,6 +64,7 @@ abstract class ExternalStoreMedium { $retval[$url] = $data; } } + return $retval; } diff --git a/includes/externalstore/ExternalStoreMwstore.php b/includes/externalstore/ExternalStoreMwstore.php index 17210077f1..f329b73477 100644 --- a/includes/externalstore/ExternalStoreMwstore.php +++ b/includes/externalstore/ExternalStoreMwstore.php @@ -43,6 +43,7 @@ class ExternalStoreMwstore extends ExternalStoreMedium { // backends should at least have "read-after-create" consistency. return $be->getFileContents( array( 'src' => $url ) ); } + return false; } @@ -66,6 +67,7 @@ class ExternalStoreMwstore extends ExternalStoreMedium { $be = FileBackendGroup::singleton()->get( $backendName ); $blobs = $blobs + $be->getFileContentsMulti( array( 'srcs' => $paths ) ); } + return $blobs; } @@ -90,6 +92,7 @@ class ExternalStoreMwstore extends ExternalStoreMedium { return $url; } } + return false; } } -- 2.20.1