[MediaWiki-commits] [Gerrit] Remove flow_text table - change (mediawiki...Flow)
Matthias Mullie has submitted this change and it was merged. Change subject: Remove flow_text table .. Remove flow_text table Merged flow_text into flow_revision, it only exists in core for historical reasons. Any wiki that expects a reasonable amount of content should set $wgFlowExternalStore to keep the bulk of content outside the revision table. To allow storage classes to assign auto-ids the WritableObjectStorage::insert method now returns an array representing the final storage state. ObjectMapper::fromStorageRow has received an additional nullable param, $object, which allows us to push those changes from insert back into the object. Revision content compression happens in AbstractRevision::setContent, decompression is handled in AbstractRevision::getContent so we lazily decompres only the content the content that is needed. Change-Id: I5cf3fe8ef0f6edb4328f4355a4abe5bec439446e --- M flow.sql M includes/Data/ObjectManager.php M includes/Data/RevisionStorage.php M includes/Model/AbstractRevision.php M includes/Model/Definition.php M includes/Model/PostRevision.php M includes/Model/Summary.php M includes/Model/TopicListEntry.php M includes/Model/Workflow.php M includes/Repository/TreeRepository.php 10 files changed, 228 insertions(+), 171 deletions(-) Approvals: Matthias Mullie: Verified; Looks good to me, approved diff --git a/flow.sql b/flow.sql index 22aa4af..caad08b 100644 --- a/flow.sql +++ b/flow.sql @@ -106,28 +106,18 @@ rev_user_text varchar(255) binary not null default '', -- rev_id of parent or null if no previous revision rev_parent_id binary(16), - + -- comma separated set of ascii flags. + rev_flags tinyblob not null, -- content of the revision - rev_text_id int unsigned not null, + rev_content mediumblob not null, -- comment attached to revision's flag change rev_comment varchar(255) binary null, - PRIMARY KEY (rev_id) ) /*$wgDBTableOptions*/; -- Prevents inconsistency, but perhaps will hurt inserts? CREATE UNIQUE INDEX /*i*/flow_revision_unique_parent ON /*_*/flow_revision (rev_parent_id); - -CREATE TABLE /*_*/flow_text ( - -- undecided on uuid, or if table is even neccessary - -- large wiki should just use external store to distribute - -- content - text_id int(10) unsigned not null auto_increment, - text_content mediumblob not null, - text_flags tinyblob not null, - PRIMARY KEY (text_id) -) /*$wgDBTableOptions*/; -- Closure table implementation of tree storage in sql -- We may be able to go simpler than this diff --git a/includes/Data/ObjectManager.php b/includes/Data/ObjectManager.php index 3d1d999..d5b2f0a 100644 --- a/includes/Data/ObjectManager.php +++ b/includes/Data/ObjectManager.php @@ -50,6 +50,9 @@ // Note that while ObjectLocator implements the above ObjectStorage interface, ObjectManger // cant use this interface because backing stores deal in rows, and OM deals in objects. interface WritableObjectStorage extends ObjectStorage { + /** +* @return array The resulting $row including any auto-assigned ids or false on failure +*/ function insert( array $row ); function update( array $old, array $new ); function remove( array $row ); @@ -62,9 +65,15 @@ function toStorageRow( $object ); /** -* Convert a db row to its domain model. +* Convert a db row to its domain model. Object passing is intended for +* updating the object to match a changed storage representation. +* +* @param array $row assoc array representing the domain model +* @param object|null $object The domain model to populate, creates when null +* @return object The domain model populated with $row +* @throws Exception When object is the wrong class for the mapper */ - function fromStorageRow( array $row ); + function fromStorageRow( array $row, $object = null ); } // An Index is just a store that receives updates via handler. @@ -330,12 +339,17 @@ protected function insert( $object ) { try { - $new = $this-mapper-toStorageRow( $object ); - $this-storage-insert( $new ); - foreach ( $this-lifecycleHandlers as $handler ) { - $handler-onAfterInsert( $object, $new ); + $row = $this-mapper-toStorageRow( $object ); + $stored = $this-storage-insert( $row ); + if ( !$stored ) { + throw new \Exception( 'failed insert' ); } - $this-loaded[$object] = $new; + // propogate auto-id's and such back into $object + $this-mapper-fromStorageRow( $stored,
[MediaWiki-commits] [Gerrit] Remove flow_text table - change (mediawiki...Flow)
EBernhardson (WMF) has uploaded a new change for review. https://gerrit.wikimedia.org/r/78313 Change subject: Remove flow_text table .. Remove flow_text table Merged flow_text into flow_revision, it only exists in core for historical reasons. Any wiki that expects a reasonable amount of content should set $wgFlowExternalStore so keep the bulk of content outside the revision table. Change-Id: I5cf3fe8ef0f6edb4328f4355a4abe5bec439446e --- M flow.sql M includes/Data/ObjectManager.php M includes/Data/RevisionStorage.php M includes/Model/AbstractRevision.php 4 files changed, 64 insertions(+), 71 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow refs/changes/13/78313/1 diff --git a/flow.sql b/flow.sql index 22aa4af..161cbf0 100644 --- a/flow.sql +++ b/flow.sql @@ -106,9 +106,10 @@ rev_user_text varchar(255) binary not null default '', -- rev_id of parent or null if no previous revision rev_parent_id binary(16), - + -- comma separated set of ascii flags. + rev_flags tinyblob not null, -- content of the revision - rev_text_id int unsigned not null, + rev_content mediumblob not null, -- comment attached to revision's flag change rev_comment varchar(255) binary null, @@ -118,16 +119,6 @@ -- Prevents inconsistency, but perhaps will hurt inserts? CREATE UNIQUE INDEX /*i*/flow_revision_unique_parent ON /*_*/flow_revision (rev_parent_id); - -CREATE TABLE /*_*/flow_text ( - -- undecided on uuid, or if table is even neccessary - -- large wiki should just use external store to distribute - -- content - text_id int(10) unsigned not null auto_increment, - text_content mediumblob not null, - text_flags tinyblob not null, - PRIMARY KEY (text_id) -) /*$wgDBTableOptions*/; -- Closure table implementation of tree storage in sql -- We may be able to go simpler than this diff --git a/includes/Data/ObjectManager.php b/includes/Data/ObjectManager.php index 3d1d999..0a5dbaa 100644 --- a/includes/Data/ObjectManager.php +++ b/includes/Data/ObjectManager.php @@ -50,7 +50,9 @@ // Note that while ObjectLocator implements the above ObjectStorage interface, ObjectManger // cant use this interface because backing stores deal in rows, and OM deals in objects. interface WritableObjectStorage extends ObjectStorage { - function insert( array $row ); + // this is a reference to allow external store inside RevisionStorage to utilize + // external store and effect updates to the cached values + function insert( array $row ); function update( array $old, array $new ); function remove( array $row ); } @@ -465,7 +467,7 @@ $this-primaryKey = $primaryKey; } - public function insert( array $row ) { + public function insert( array $row ) { // insert returns boolean true/false return $this-dbFactory-getDB( DB_MASTER )-insert( $this-table, diff --git a/includes/Data/RevisionStorage.php b/includes/Data/RevisionStorage.php index aa05ce4..532a12a 100644 --- a/includes/Data/RevisionStorage.php +++ b/includes/Data/RevisionStorage.php @@ -10,7 +10,7 @@ use User; abstract class RevisionStorage implements WritableObjectStorage { - static protected $allowedUpdateColumns = array( 'text_flags' ); + static protected $allowedUpdateColumns = array( 'rev_flags' ); protected $dbFactory; protected $externalStores; @@ -40,15 +40,12 @@ protected function findInternal( array $attributes, array $options = array() ) { $dbr = $this-dbFactory-getDB( DB_MASTER ); $res = $dbr-select( - array( $this-joinTable(), 'rev' = 'flow_revision', 'text' = 'flow_text' ), + array( $this-joinTable(), 'rev' = 'flow_revision' ), '*', UUID::convertUUIDs( $attributes ), __METHOD__, $options, - array( - 'rev' = array( 'JOIN', $this-joinField() . ' = rev_id' ), - 'text' = array( 'JOIN', text_id = rev_text_id ), - ) + array( 'rev' = array( 'JOIN', $this-joinField() . ' = rev_id' ) ) ); if ( !$res ) { return null; @@ -69,7 +66,7 @@ if ( $this-externalStore ) { $res = Merger::mergeMulti( $res, - 'text_content', + 'rev_content', array( 'ExternalStore', 'batchFetchFromURLs' ) ); } @@ -77,8 +74,8 @@ // decompress