*/
class ExternalStore {
var $mParams;
-
+
+ /**
+ * @param $params array
+ */
function __construct( $params = array() ) {
$this->mParams = $params;
}
-
+
/**
* Fetch data from given URL
*
static function fetchFromURL( $url, $params = array() ) {
global $wgExternalStores;
- if( !$wgExternalStores )
+ if( !$wgExternalStores ) {
return false;
+ }
$parts = explode( '://', $url, 2 );
}
$store = self::getStoreObject( $proto, $params );
- if ( $store === false )
+ if ( $store === false ) {
return false;
+ }
+
return $store->fetchFromURL( $url );
}
*
* @param $proto String: type of external storage, should be a value in $wgExternalStores
* @param $params Array: associative array of parameters for the ExternalStore object.
- * @return ExternalStore subclass or false on error
+ * @return ExternalStore|bool ExternalStore class or false on error
*/
static function getStoreObject( $proto, $params = array() ) {
global $wgExternalStores;
- if( !$wgExternalStores )
+ if( !$wgExternalStores ) {
return false;
+ }
+
/* Protocol not enabled */
- if( !in_array( $proto, $wgExternalStores ) )
+ if( !in_array( $proto, $wgExternalStores ) ) {
return false;
+ }
$class = 'ExternalStore' . ucfirst( $proto );
/* Any custom modules should be added to $wgAutoLoadClasses for on-demand loading */
return $store->store( $params, $data );
}
}
-
+
/**
* Like insert() above, but does more of the work for us.
* This function does not need a url param, it builds it by
*
* @param $data String
* @param $storageParams Array: associative array of parameters for the ExternalStore object.
- * @return string The URL of the stored data item, or false on error
+ * @throws MWException|DBConnectionError|DBQueryError
+ * @return string|bool The URL of the stored data item, or false on error
*/
public static function insertToDefault( $data, $storageParams = array() ) {
global $wgDefaultExternalStore;
throw new MWException( "Unable to store text to external storage" );
}
}
-
+
/**
* @param $data
* @param $wiki