EBernhardson (WMF) has submitted this change and it was merged.

Change subject: More work finishing up UUID handling
......................................................................


More work finishing up UUID handling

A few column names changed, tree_ancestor, tree_descendant, and 
tree_rev_descendant
were all renamed to have '_id' at the end(ex: tree_ancestor_id) so that they 
can receive
"auto" conversion from hex to binary in the query code path.

Ensure UUID comparrisons are being done with the correct formats in various 
places

Some extra debugging that will bail out if we try to send or receive objects (
                rather than the expected scalar|null) to memcached.

Indexes now bail out if you attempt to add/remove an unindexable value from the 
index

Change-Id: I0f32122efd075ba28da6edb43407c9211cf957d9
---
M container.php
M flow.sql
M includes/Block/Block.php
M includes/Block/Summary.php
M includes/Block/Topic.php
M includes/Data/ObjectManager.php
M includes/Data/RevisionStorage.php
M includes/Data/RootPostLoader.php
M includes/Model/PostRevision.php
M includes/Model/Workflow.php
M includes/Repository/TreeRepository.php
11 files changed, 114 insertions(+), 82 deletions(-)

Approvals:
  EBernhardson (WMF): Verified; Looks good to me, approved



diff --git a/container.php b/container.php
index 5f15341..4bd0e1f 100644
--- a/container.php
+++ b/container.php
@@ -6,7 +6,8 @@
 $c['user'] = $GLOBALS['wgUser'];
 $c['output'] = $GLOBALS['wgOut'];
 $c['request'] = $GLOBALS['wgRequest'];
-$c['memcache'] = new \HashBagOStuff; //$GLOBALS['wgMemc'];
+//$c['memcache'] = new \HashBagOStuff;
+$c['memcache'] = $GLOBALS['wgMemc'];
 
 // Always returns the correct database for flow storage
 $c['db.factory'] = $c->share( function( $c ) {
@@ -172,7 +173,7 @@
        $indexes = array(
                new UniqueFeatureIndex( $cache, $storage, 'flow_revision:pk', 
array( 'rev_id' ) ),
                new TopKIndex( $cache, $storage, 'flow_revision:descendant',
-                       array( 'tree_rev_descendant' ),
+                       array( 'tree_rev_descendant_id' ),
                        array(
                                'limit' => 100,
                                'sort' => 'rev_id',
@@ -184,7 +185,7 @@
                                },
                ) ),
                new TopKIndex( $cache, $storage, 'flow_revision:latest_post',
-                       array( 'tree_rev_descendant' ),
+                       array( 'tree_rev_descendant_id' ),
                        array(
                                'limit' => 1,
                                'sort' => 'rev_id',
diff --git a/flow.sql b/flow.sql
index a7f24e9..5d9dbaa 100644
--- a/flow.sql
+++ b/flow.sql
@@ -53,7 +53,7 @@
 -- also denormalizes information commonly needed with a revision
 CREATE TABLE /*_*/flow_tree_revision (
        -- the id of the post in the post tree
-       tree_rev_descendant binary(16) not null,
+       tree_rev_descendant_id binary(16) not null,
        -- fk to flow_revision
        tree_rev_id binary(16) not null,
        -- denormalized so we dont need to keep finding the first revision of a 
post
@@ -66,8 +66,8 @@
        PRIMARY KEY( tree_rev_id )
 ) /*$wgDBTableOptions*/;
 
-CREATE UNIQUE INDEX /*i*/flow_tree_descendant_revisions 
-       ON /*_*/flow_tree_revision ( tree_rev_descendant, tree_rev_id );
+CREATE UNIQUE INDEX /*i*/flow_tree_descendant_id_revisions 
+       ON /*_*/flow_tree_revision ( tree_rev_descendant_id, tree_rev_id );
 
 -- Summary Content
 -- Instead of summary, should this be more generic 'revisioned scratchpad' 
@@ -135,13 +135,13 @@
 -- Closure table implementation of tree storage in sql
 -- We may be able to go simpler than this
 CREATE TABLE /*_*/flow_tree_node (
-       tree_ancestor binary(16) not null,
-       tree_descendant binary(16) not null,
+       tree_ancestor_id binary(16) not null,
+       tree_descendant_id binary(16) not null,
        tree_depth smallint not null
 ) /*$wgDBTableOptions*/;
 
-CREATE UNIQUE INDEX /*i*/flow_tree_node_pk ON /*_*/flow_tree_node 
(tree_ancestor, tree_descendant);
-CREATE UNIQUE INDEX /*i*/flow_tree_constraint ON /*_*/flow_tree_node 
(tree_descendant, tree_depth);
+CREATE UNIQUE INDEX /*i*/flow_tree_node_pk ON /*_*/flow_tree_node 
(tree_ancestor_id, tree_descendant_id);
+CREATE UNIQUE INDEX /*i*/flow_tree_constraint ON /*_*/flow_tree_node 
(tree_descendant_id, tree_depth);
 
 -- These dont belong here
 INSERT INTO flow_definition
diff --git a/includes/Block/Block.php b/includes/Block/Block.php
index 4605606..d60bdbd 100644
--- a/includes/Block/Block.php
+++ b/includes/Block/Block.php
@@ -54,7 +54,7 @@
        abstract public function commit();
 
        public function init( $action ) {
-
+               $this->action = $action;
        }
 
        public function onSubmit( $action, User $user, array $data  ) {
@@ -62,7 +62,6 @@
                        return null;
                }
 
-               $this->action = $action;
                $this->user = $user;
                $this->submitted = $data;
 
diff --git a/includes/Block/Summary.php b/includes/Block/Summary.php
index 60577b6..f2c62bf 100644
--- a/includes/Block/Summary.php
+++ b/includes/Block/Summary.php
@@ -17,6 +17,7 @@
        protected $supportedActions = array( 'edit-summary' );
 
        public function init( $action ) {
+               parent::init( $action );
                if ( $this->workflow->isNew() ) {
                        $this->needCreate = true;
                        return;
@@ -37,16 +38,19 @@
                if ( $this->summary ) {
                        if ( empty( $this->submitted['prev_revision'] ) ) {
                                $this->errors['prev_revision'] = wfMessage( 
'flow-missing-prev-revision-identifier' );
-                       } elseif ( $this->summary->getRevisionId() !== 
$this->submitted['prev_revision'] ) {
-                               // This is *NOT* an effective way to ensure 
prev revision matches, that needs
-                               // to be done at the database level when 
commiting.  This is just a short circuit.
-                               $this->errors['prev_revision'] = wfMessage( 
'flow-prev-revision-mismatch' );
+                       } elseif ( $this->summary->getRevisionId()->getHex() 
!== $this->submitted['prev_revision'] ) {
+                               // This is a reasonably effective way to ensure 
prev revision matches, but for guarantees against race
+                               // conditions there also exists a unique index 
on rev_prev_revision in mysql, meaning if someone else inserts against the
+                               // parent we and the submitter think is the 
latest, our insert will fail.
+                               // TODO: Catch whatever exception happens 
there, make sure the most recent revision is the one in the cache before
+                               // handing user back to specific dialog 
indicating race condition
+                               $this->errors['prev_revision'] = wfMessage( 
'flow-prev-revision-mismatch' )->params( $this->submitted['prev_revision'], 
$this->summary->getRevisionId()->getHex() );
                        }
-                       // this isnt really part of validate,
+                       // this isnt really part of validate, but we want the 
error-rendering template to see the users edited summary
                        $this->summary = $this->summary->newNextRevision( 
$this->user, $this->submitted['content'] );
                } else {
                        if ( empty( $this->submitted['prev_revision'] ) ) {
-                               // this isnt really part of validate either ... 
:-(
+                               // this isnt really part of validate either, 
should validate be renamed or should this logic be redone?
                                $this->summary = Summary::create( 
$this->workflow, $this->user, $this->submitted['content'] );
                        } else {
                                // User submitted a previous revision, but we 
couldn't find one.  This is likely
@@ -66,6 +70,9 @@
        public function commit() {
                switch( $this->action ) {
                case 'edit-summary':
+                       if ( $this->summary ) {
+                               $summary = $this-
+                       }
                        $this->storage->put( $this->summary );
                        break;
 
diff --git a/includes/Block/Topic.php b/includes/Block/Topic.php
index 9c0f18a..5b377bc 100644
--- a/includes/Block/Topic.php
+++ b/includes/Block/Topic.php
@@ -32,10 +32,6 @@
                }
        }
 
-       public function init( $action ) {
-               $this->action = $action;
-       }
-
        protected function validate() {
                switch( $this->action ) {
                case 'reply':
@@ -86,21 +82,19 @@
        }
 
        protected function validateDeleteTopic() {
-               global $wgUser; // ugh
-               if ( !$this->workflow->lock( $wgUser ) ) {
+               if ( !$this->workflow->lock( $this->user ) ) {
                        $this->errors['delete-topic'] = wfMessage( 
'flow-delete-topic-failed' );
                }
        }
 
        protected function validateDeletePost() {
-               global $wgUser; // ugh
                if ( empty( $this->submitted['postId'] ) ) {
                        $this->errors['delete-post'] = wfMessage( 
'flow-no-post-provided' );
                        return;
                }
                $found = $this->storage->find(
                        'PostRevision',
-                       array( 'tree_rev_descendant' => UUID::create( 
$this->submitted['postId'] ) ),
+                       array( 'tree_rev_descendant_id' => UUID::create( 
$this->submitted['postId'] ) ),
                        array( 'sort' => 'rev_id', 'order' => 'DESC', 'limit' 
=> 1 )
                );
                if ( !$found ) {
@@ -111,21 +105,20 @@
                $post = reset( $found );
 
                // returns new revision to save
-               $this->newRevision = $post->addFlag( $wgUser, 'deleted', 
'flow-comment-deleted' );
+               $this->newRevision = $post->addFlag( $this->user, 'deleted', 
'flow-comment-deleted' );
                if ( !$this->newRevision ) {
                        $this->errors['delete-post'] = wfMessage( 
'flow-delete-post-failed' );
                }
        }
 
        protected function validateRestorePost() {
-               global $wgUser;
                if ( empty( $this->submitted['postId'] ) ) {
                        $this->errors['restore-post'] = wfMessage( 
'flow-no-post-provided' );
                        return;
                }
                $found = $this->storage->find(
                        'PostRevision',
-                       array( 'tree_rev_descendant' => UUID::create( 
$this->submitted['postId'] ) ),
+                       array( 'tree_rev_descendant_id' => UUID::create( 
$this->submitted['postId'] ) ),
                        array( 'sort' => 'rev_id', 'order' => 'DESC', 'limit' 
=> 1 )
                );
                if ( !$found ) {
@@ -134,7 +127,7 @@
                }
                $post = reset( $found );
 
-               $this->newRevision = $post->removeFlag( $wgUser, 'deleted', 
'flow-comment-restored' );
+               $this->newRevision = $post->removeFlag( $this->user, 'deleted', 
'flow-comment-restored' );
                if ( !$this->newRevision ) {
                        $this->errors['restore-post'] = wfMessage( 
'flow-post-restore-failed' );
                }
@@ -186,7 +179,7 @@
                        } else {
                                $history = $this->storage->find(
                                        'PostRevision',
-                                       array( 'tree_rev_descendant' => 
UUID::create( $options['postId'] ) ),
+                                       array( 'tree_rev_descendant_id' => 
UUID::create( $options['postId'] ) ),
                                        array( 'sort' => 'rev_id', 'order' => 
'DESC', 'limit' => 100 )
                                );
                        }
diff --git a/includes/Data/ObjectManager.php b/includes/Data/ObjectManager.php
index 76efa71..da107fd 100644
--- a/includes/Data/ObjectManager.php
+++ b/includes/Data/ObjectManager.php
@@ -331,6 +331,11 @@
                try {
                        $old = $this->loaded[$object];
                        $new = $this->mapper->toStorageRow( $object );
+                       foreach ( $new as $k => $x ) {
+                               if ( $x !== null && !is_scalar( $x ) ) {
+                                       throw new \RuntimeException( "Expected 
mapper to return all scalars, but '$k' is " . gettype( $x ) );
+                               }
+                       }
                        if ( self::arrayEquals( $old, $new ) ) {
                                return;
                        }
@@ -566,7 +571,7 @@
 }
 
 /**
- * Index objects with similar features into the same buckets.
+ * Index objects with equal features($indexedColumns) into the same buckets.
  */
 abstract class FeatureIndex implements Index {
 
@@ -621,9 +626,10 @@
        public function onAfterInsert( $object, array $new) {
                $indexed = ObjectManager::splitFromRow( $new , $this->indexed );
                // is un-indexable a bail-worthy occasion? Probably not
-               if ( $indexed ) {
-                       $this->addToIndex( $indexed, $this->compactRow( $new ) 
);
+               if ( !$indexed ) {
+                       throw new \MWException( 'Unindexable row: ' 
.json_encode( $new ) );
                }
+               $this->addToIndex( $indexed, $this->compactRow( $new ) );
        }
 
        public function onAfterUpdate( $object, array $old, array $new ) {
@@ -632,19 +638,22 @@
                // TODO: optimize $oldIndexed === $newIndexed, which should be 
common
                // TODO: optimize out occurances where data changed but not the 
values
                //       indexed or stored in the index(for shallow indexes)
-               if ( $oldIndexed ) {
-                       $this->removeFromIndex( $oldIndexed, $this->compactRow( 
$old ) );
+               if ( !$oldIndexed ) {
+                       throw new \MWException( 'Unindexable row: ' 
.json_encode( $oldIndexed ) );
                }
-               if ( $newIndexed ) {
-                       $this->addToIndex( $newIndexed, $this->compactRow( $new 
) );
+               if ( !$newIndexed ) {
+                       throw new \MWException( 'Unindexable row: ' 
.json_encode( $newIndexed ) );
                }
+               $this->removeFromIndex( $oldIndexed, $this->compactRow( $old ) 
);
+               $this->addToIndex( $newIndexed, $this->compactRow( $new ) );
        }
 
        public function onAfterRemove( $object, array $old ) {
                $indexed = ObjectManager::splitFromRow( $old, $this->indexed );
-               if ( $indexed ) {
-                       $this->removeFromIndex( $indexed, $this->compactRow( 
$old ) );
+               if ( !$indexed ) {
+                       throw new \MWException( 'Unindexable row: ' 
.json_encode( $old ) );
                }
+               $this->removeFromIndex( $indexed, $this->compactRow( $old ) );
        }
 
        public function onAfterLoad( $object, array $old ) {
@@ -675,7 +684,7 @@
                        $keyToIdx[$key][] = $idx;
                        if ( !isset( $keyToQuery[$key] ) ) {
                                $idxToKey[$idx] = $key;
-                               $keyToQuery[$key] = $query;
+                               $keyToQuery[$key] = UUID::convertUUIDs( $query 
);
                        }
                }
 
@@ -699,6 +708,13 @@
                        if ( !$rows ) {
                                // Nothing found,  should we cache failures as 
well as success?
                                continue;
+                       }
+                       foreach( $rows as $row ) {
+                               foreach ( $row as $k => $foo ) {
+                                       if ( $foo !== null && !is_scalar( $foo 
) ) {
+                                               throw new \Exception( "Received 
non-scalar row value for '$k' from: " . get_class( $this->storage ) );
+                                       }
+                               }
                        }
                        $this->cache->add( $idxToKey[$idx], $this->compactRows( 
$rows ) );
                        $results[$idx] = $rows;
@@ -741,6 +757,11 @@
                foreach ( $this->indexed as $key ) {
                        unset( $row[$key] );
                }
+               foreach ( $row as $foo ) {
+                       if ( $foo !== null && !is_scalar( $foo ) ) {
+                               throw new \MWException( 'Attempted to compact 
row containing objects, must be scalar values: ' . print_r( $foo, true ) );
+                       }
+               }
                return $row;
        }
 
@@ -758,7 +779,17 @@
                foreach ( $cached as $key => $rows ) {
                        $expanded = array();
                        $query = $keyToQuery[$key];
+                       foreach ( $query as $foo ) {
+                               if ( $foo !== null && !is_scalar( $foo ) ) {
+                                       throw new \MWException( 'Query values 
to merge with cache contains objects, should be scalar values: ' . print_r( 
$foo, true ) );
+                               }
+                       }
                        foreach ( $rows as $k => $row ) {
+                               foreach ( $row as $foo ) {
+                                       if ( $foo !== null && !is_scalar( $foo 
) ) {
+                                               throw new \MWException( 'Result 
from cache contains objects, should be scalar values: ' . print_r( $foo, true ) 
);
+                                       }
+                               }
                                $cached[$key][$k] = $row + $query;
                        }
                }
@@ -798,7 +829,7 @@
 }
 
 /**
- * Holds the top k items matching
+ * Holds the top k items with matching $indexed columns.  List is sorted and 
truncated to specified size.
  */
 class TopKIndex extends FeatureIndex {
        public function __construct( BufferedCache $cache, ObjectStorage 
$storage, $prefix, array $indexed, array $options = array() ) {
@@ -899,6 +930,8 @@
        }
 
        protected function compactRow( array $row ) {
+               // An OO solution wouldn't check this, it would have a 
compact/expand
+               // implementation
                if ( isset( $this->options['shallow'] ) ) {
                        $keys = array_merge(
                                
$this->options['shallow']->getPrimaryKeyColumns(),
@@ -955,6 +988,13 @@
 
 }
 
+/**
+ * Performs the equivilent of an SQL ORDER BY c1 ASC, c2 ASC...
+ * Always sorts in ascending order.  array_reverse to get all descending.
+ * For varied asc/desc needs implementation changes.
+ *
+ * usage: usort( $array, new SortArrayByKeys( array( 'c1', 'c2' ) ) );
+ */
 class SortArrayByKeys {
        protected $keys;
        protected $strict;
diff --git a/includes/Data/RevisionStorage.php 
b/includes/Data/RevisionStorage.php
index 22a65fb..47f2a01 100644
--- a/includes/Data/RevisionStorage.php
+++ b/includes/Data/RevisionStorage.php
@@ -121,8 +121,8 @@
        protected function findMostRecent( array $queries ) {
                // SELECT MAX(tree_rev_id) AS tree_rev_id
                //   FROM flow_tree_revision
-               //  WHERE tree_rev_descendant IN (...)
-               //  GROUP BY tree_rev_descendant
+               //  WHERE tree_rev_descendant_id IN (...)
+               //  GROUP BY tree_rev_descendant_id
                //
                //  Could we instead use this?
                //
@@ -130,8 +130,8 @@
                //      FROM flow_tree_revision rev
                //      JOIN ( SELECT MAX(tree_rev_id) as tree_rev_id
                //                       FROM flow_tree_revision
-               //                      WHERE tree_rev_descendant IN (...)
-               //                      GROUP BY tree_rev_descendant
+               //                      WHERE tree_rev_descendant_id IN (...)
+               //                      GROUP BY tree_rev_descendant_id
                //               ) max ON max.tree_rev_id = rev.tree_rev_id
                //
                $duplicator = new ResultDuplicator( array_keys( reset( $queries 
) ), 1 );
@@ -194,7 +194,7 @@
                $keys = array_keys( reset( $queries ) );
                $conditions = array();
                if ( count( $keys ) === 1 ) {
-                       // standard in condition: tree_rev_descendant IN 
(1,2...)
+                       // standard in condition: tree_rev_descendant_id IN 
(1,2...)
                        $key = reset( $keys );
                        foreach ( $queries as $query ) {
                                $conditions[$key][] = reset( $query );
@@ -234,7 +234,7 @@
        protected function insertContent( $data ) {
                $flags = \Revision::compressRevisionText( $data );
 
-               if ( $this-externalStore ) {
+               if ( $this->externalStore ) {
                        // Store and get the URL
                        $data = ExternalStore::insertWithFallback( 
$this->externalStore, $data );
                        if ( !$data ) {
@@ -342,7 +342,7 @@
        }
 
        protected function relatedPk() {
-               return 'tree_rev_descendant';
+               return 'tree_rev_descendant_id';
        }
 
        protected function joinField() {
@@ -353,17 +353,18 @@
                $dbw = $this->dbFactory->getDB( DB_MASTER );
                $res = $dbw->insert(
                        $this->joinTable(),
-                       $tree,
+                       UUID::convertUUIDs( $tree ),
                        __METHOD__
                );
                if ( !$res ) {
                        return false;
                }
 
-               // If this is a brand new root revision
+               // If this is a brand new root revision it needs to be added to 
the tree
+               // If it has a rev_parent_id then its already a part of the tree
                if ( $row['rev_parent_id'] === null ) {
                        return (bool) $this->treeRepo->insert(
-                               UUID::create( $tree['tree_rev_descendant'] ),
+                               UUID::create( $tree['tree_rev_descendant_id'] ),
                                UUID::create( $tree['tree_parent_id'] )
                        );
                }
diff --git a/includes/Data/RootPostLoader.php b/includes/Data/RootPostLoader.php
index 9934a77..6c98c9e 100644
--- a/includes/Data/RootPostLoader.php
+++ b/includes/Data/RootPostLoader.php
@@ -28,7 +28,7 @@
                $allPostIds =  $this->fetchRelatedPostIds( $topicIds );
                $queries = array();
                foreach ( $allPostIds as $postId ) {
-                       $queries[] = array( 'tree_rev_descendant' => $postId );
+                       $queries[] = array( 'tree_rev_descendant_id' => $postId 
);
                }
                $found = $this->storage->findMulti( 'PostRevision', $queries, 
array(
                        'sort' => 'rev_id',
diff --git a/includes/Model/PostRevision.php b/includes/Model/PostRevision.php
index 3be1956..1617faa 100644
--- a/includes/Model/PostRevision.php
+++ b/includes/Model/PostRevision.php
@@ -41,7 +41,7 @@
                $obj = parent::fromStorageRow( $row );
 
                $obj->replyToId = UUID::create( $row['tree_parent_id'] );
-               $obj->postId = UUID::create( $row['tree_rev_descendant'] );
+               $obj->postId = UUID::create( $row['tree_rev_descendant_id'] );
                $obj->origCreateTime = $row['tree_orig_create_time'];
                $obj->origUserId = $row['tree_orig_user_id'];
                $obj->origUserText = $row['tree_orig_user_text'];
@@ -52,7 +52,7 @@
        static public function toStorageRow( $rev ) {
                return parent::toStorageRow( $rev ) + array(
                        'tree_parent_id' => $rev->replyToId ? 
$rev->replyToId->getBinary() : null,
-                       'tree_rev_descendant' => $rev->postId->getBinary(),
+                       'tree_rev_descendant_id' => $rev->postId->getBinary(),
                        'tree_rev_id' => $rev->revId->getBinary(),
                        // rest of tree_ is denormalized data about first post 
revision
                        'tree_orig_create_time' => $rev->origCreateTime,
diff --git a/includes/Model/Workflow.php b/includes/Model/Workflow.php
index 1060dd5..0b0ad54 100644
--- a/includes/Model/Workflow.php
+++ b/includes/Model/Workflow.php
@@ -35,9 +35,6 @@
        }
 
        static public function toStorageRow( Workflow $obj ) {
-               if ( ! $obj->definitionId instanceof UUID ) {
-                       die( var_dump( $obj->definitionId, $obj ) );
-               }
                return array(
                        'workflow_id' => $obj->id->getBinary(),
                        'workflow_wiki' => $obj->wiki,
@@ -76,9 +73,6 @@
                $obj->lockState = 0;
                $obj->definitionId = $definition->getId();
 
-               if ( ! $obj->definitionId instanceof UUID ) {
-                       die( var_dump( $obj, $definition ) );
-               }
                return $obj;
        }
 
@@ -123,9 +117,6 @@
                        return false; // non-existant page
                }
                if ( $title->getNamespace() !== $this->namespace ) {
-                       var_dump( $title->getNamespace() );
-                       var_dump( $this->namespace );
-                       die();
                        throw new \Exception( 'namespace' );
                }
                if ( $title->getDBkey() !== $this->titleText ) {
diff --git a/includes/Repository/TreeRepository.php 
b/includes/Repository/TreeRepository.php
index 7478f6f..d88bd94 100644
--- a/includes/Repository/TreeRepository.php
+++ b/includes/Repository/TreeRepository.php
@@ -68,8 +68,8 @@
                $res = $dbw->insert(
                        $this->tableName,
                        array(
-                               'tree_descendant' => $descendant->getBinary(),
-                               'tree_ancestor' => $descendant->getBinary(),
+                               'tree_descendant_id' => 
$descendant->getBinary(),
+                               'tree_ancestor_id' => $descendant->getBinary(),
                                'tree_depth' => 0,
                        ),
                        __METHOD__
@@ -79,12 +79,12 @@
                                $this->tableName,
                                $this->tableName,
                                array(
-                                       'tree_descendant' => $dbw->addQuotes( 
$descendant->getBinary() ),
-                                       'tree_ancestor' => 'tree_ancestor',
+                                       'tree_descendant_id' => 
$dbw->addQuotes( $descendant->getBinary() ),
+                                       'tree_ancestor_id' => 
'tree_ancestor_id',
                                        'tree_depth' => 'tree_depth + 1',
                                ),
                                array(
-                                       'tree_descendant' => 
$ancestor->getBinary(),
+                                       'tree_descendant_id' => 
$ancestor->getBinary(),
                                ),
                                __METHOD__
                        );
@@ -133,9 +133,9 @@
                $dbr = $this->dbFactory->getDB( DB_SLAVE );
                $res = $dbr->select(
                        $this->tableName,
-                       array( 'tree_ancestor', 'tree_depth' ),
+                       array( 'tree_ancestor_id', 'tree_depth' ),
                        array(
-                               'tree_descendant' => $descendant->getBinary(),
+                               'tree_descendant_id' => 
$descendant->getBinary(),
                        ),
                        __METHOD__
                );
@@ -143,7 +143,7 @@
                        return null;
                }
                foreach ( $res as $row ) {
-                       $path[$row->tree_depth] = UUID::create( 
$row->tree_ancestor );
+                       $path[$row->tree_depth] = UUID::create( 
$row->tree_ancestor_id );
                }
                ksort( $path );
                $path = array_reverse( $path );
@@ -217,9 +217,9 @@
        public function fetchSubtreeNodeListFromDb( array $roots ) {
                $res = $this->dbFactory->getDB( DB_SLAVE )->select(
                        $this->tableName,
-                       array( 'tree_ancestor', 'tree_descendant' ),
+                       array( 'tree_ancestor_id', 'tree_descendant_id' ),
                        array(
-                               'tree_ancestor' => UUID::convertUUIDs( $roots ),
+                               'tree_ancestor_id' => UUID::convertUUIDs( 
$roots ),
                        ),
                        __METHOD__
                );
@@ -228,8 +228,8 @@
                }
                $nodes = array();
                foreach ( $res as $node ) {
-                       $ancestor = UUID::create( $node->tree_ancestor );
-                       $descendant = UUID::create( $node->tree_descendant );
+                       $ancestor = UUID::create( $node->tree_ancestor_id );
+                       $descendant = UUID::create( $node->tree_descendant_id );
                        $nodes[$ancestor->getHex()][$descendant->getHex()] = 
$descendant;
                }
 
@@ -254,9 +254,9 @@
                $dbr = $this->dbFactory->getDB( DB_SLAVE );
                $res = $dbr->select(
                        $this->tableName,
-                       array( 'tree_ancestor', 'tree_descendant' ),
+                       array( 'tree_ancestor_id', 'tree_descendant_id' ),
                        array(
-                               'tree_descendant' => $nodes,
+                               'tree_descendant_id' => $nodes,
                                'tree_depth' => 1,
                        ),
                        __METHOD__
@@ -266,11 +266,11 @@
                }
                $result = array();
                foreach ( $res as $node ) {
-                       if ( isset( $result[$node->tree_descendant] ) ) {
-                               throw new MWException( 'Already have a parent 
for ' . $node->tree_descendant );
+                       if ( isset( $result[$node->tree_descendant_id] ) ) {
+                               throw new MWException( 'Already have a parent 
for ' . $node->tree_descendant_id );
                        }
-                       $descendant = UUID::create( $node->tree_descendant );
-                       $result[$descendant->getHex()] = UUID::create( 
$node->tree_ancestor );
+                       $descendant = UUID::create( $node->tree_descendant_id );
+                       $result[$descendant->getHex()] = UUID::create( 
$node->tree_ancestor_id );
                }
                foreach ( $nodes as $node ) {
                        if ( !isset( $result[$node] ) ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/78188
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0f32122efd075ba28da6edb43407c9211cf957d9
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson (WMF) <[email protected]>
Gerrit-Reviewer: EBernhardson (WMF) <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to