*/
$wgExternalServers = array();
+/**
+ * The place to put new revisions, false to put them in the local text table.
+ * Part of a URL, e.g. DB://cluster1
+ */
+$wgDefaultExternalStore = false;
+
/**
* list of trusted media-types and mime types.
* Use the MEDIATYPE_xxx constants to represent media types.
/* Bad URL */
if ($path=="")
return false;
+
+ $store =& ExternalStore::getStoreObject( $proto );
+ if ( $store === false )
+ return false;
+ return $store->fetchFromURL($url);
+ }
+
+ /**
+ * Get an external store object of the given type
+ */
+ function &getStoreObject( $proto ) {
+ global $wgExternalStores;
+ if (!$wgExternalStores)
+ return false;
/* Protocol not enabled */
if (!in_array( $proto, $wgExternalStores ))
return false;
return false;
}
$store=new $class();
- return $store->fetchFromURL($url);
+ return $store;
}
- /* XXX: may require other methods, for store, delete,
- * whatever, for initial ext storage
+ /**
+ * Store a data item to an external store, identified by a partial URL
+ * The protocol part is used to identify the class, the rest is passed to the
+ * class itself as a parameter.
+ * Returns the URL of the stored data item, or false on error
*/
+ function insert( $url, $data ) {
+ list( $proto, $params ) = explode( '://', $url, 2 );
+ $store =& ExternalStore::getStoreObject( $proto );
+ if ( $store === false ) {
+ return false;
+ } else {
+ return $store->store( $params, $data );
+ }
+ }
}
?>
$id = $dbw->nextSequenceValue( 'blob_blob_id_seq' );
$dbw->insert( $this->getTable( $dbw ), array( 'blob_id' => $id, 'blob_text' => $data ), $fname );
- return "DB://$cluster/" . $dbw->insertId();
+ $id = $dbw->insertId();
+ if ( $dbw->getFlag( DBO_TRX ) ) {
+ $dbw->immediateCommit();
+ }
+ return "DB://$cluster/$id";
}
}
?>
* @return int
*/
function insertOn( &$dbw ) {
+ global $wgDefaultExternalStore;
+
$fname = 'Revision::insertOn';
wfProfileIn( $fname );
- $mungedText = $this->mText;
- $flags = Revision::compressRevisionText( $mungedText );
+ $data = $this->mText;
+ $flags = Revision::compressRevisionText( $data );
- # Record the text to the text table
+ # Write to external storage if required
+ if ( $wgDefaultExternalStore ) {
+ require_once('ExternalStore.php');
+ // Store and get the URL
+ $data = ExternalStore::insert( $wgDefaultExternalStore, $data );
+ if ( !$data ) {
+ # This should only happen in the case of a configuration error, where the external store is not valid
+ wfDebugDieBacktrace( "Unable to store text to external storage $wgDefaultExternalStore" );
+ }
+ if ( $flags ) {
+ $flags .= ',';
+ }
+ $flags .= 'external';
+ }
+
+ # Record the text (or external storage URL) to the text table
if( !isset( $this->mTextId ) ) {
$old_id = $dbw->nextSequenceValue( 'text_old_id_val' );
$dbw->insert( 'text',
array(
'old_id' => $old_id,
- 'old_text' => $mungedText,
+ 'old_text' => $data,
'old_flags' => $flags,
), $fname
);