jenkins-bot has submitted this change and it was merged.

Change subject: Fixup a few MW related issues
......................................................................


Fixup a few MW related issues

- Prefixes and table options to mysql tables
- Undefined variable
- Documenation

Change-Id: Ic62569319e385dcb4b319f75d4bc632e835bd6c5
---
M Tries.php
M TriesA5.php
M blamemaps.php
M createTable.sql
4 files changed, 48 insertions(+), 19 deletions(-)

Approvals:
  Krinkle: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Tries.php b/Tries.php
index 2581683..69673cc 100644
--- a/Tries.php
+++ b/Tries.php
@@ -6,8 +6,7 @@
  * necessary for constructing a tree
  * for naive trie algorithm
  */
-class Tries
-{
+class Tries {
        /**
         * information about nodes is stored in array $nodes (array of arrays)
         * $nodes[$nodeId] returns an array, say, $node which
@@ -88,6 +87,7 @@
                // inserting root
                $this->addNode( 0 );
        }
+
        /**
         * adds revision
         * revision is array of tokens
@@ -113,6 +113,7 @@
                // $th = $this->getTruncateThreshold();
                // $this->truncateTree( $th );
        }
+
        /**
         * method adds string $this->revision[startIdx] ... [endIdx] to the tree
         * to do this we traverse down the tree matching the string along
@@ -173,6 +174,7 @@
                        return;
                }
        }
+
        /**
         * adds node to array $nodes with $nodeId
         * returns id if a new node
@@ -214,6 +216,7 @@
                $this->nodes[$destNodeId][self::NODE_LAST_VISIT] = 
$this->crNumber;
                return $e;
        }
+
        protected function getNewNodeId() {
                $this->linId += 1;
                return $this->linId;
@@ -252,6 +255,7 @@
                $this->addEdge( $middleNodeId, $eDestNodeIdOld, $secondPartOfe 
);
                return $middleNodeId;
        }
+
        protected function calculateCurrentCovering() {
                $result = array();
                $labelArray = array();
@@ -274,12 +278,14 @@
                }
                $this->cCovering = $result;
        }
+
        /**
         * method returns covering for current revision
         */
        public function getCurrentCovering() {
                return $this->cCovering;
        }
+
        /**
         * given string s of length N method
         * returns leaf id that string path
@@ -329,6 +335,7 @@
                        return null;
                }
        }
+
        /**
         * method deletes nodes and edges that were
         * visited more than "threshold" revisions ago
@@ -361,6 +368,7 @@
                        unset( $this->nodes[$nodeId] );
                }
        }
+
        /**
         * calculates threshold for truncating nodes.
         * all nodes that were visited more than $threshold
@@ -374,6 +382,7 @@
                $value = max( $this->crNumber - $revisionOldest, 
$this->K_revisions );
                return $value;
        }
+
        /**
         * time table is needed for truncating
         * nodes of the tree. Timetable is an array
@@ -452,6 +461,7 @@
                }
                return $result;
        }
+
        /**
         * loads tree from json
         */
@@ -594,6 +604,7 @@
        public function testGetNodes() {
                return $this->nodes;
        }
+
        public function testGetEdges() {
                return $this->edges;
        }
diff --git a/TriesA5.php b/TriesA5.php
index c67cfcb..fc88e1b 100644
--- a/TriesA5.php
+++ b/TriesA5.php
@@ -15,8 +15,7 @@
 //                - add saving class values like N, K_rev, K_time, cr_timestamp
 //                - change timestamp format
 //                - add author fields in $this->add_revision method
-class TriesA5
-{
+class TriesA5 {
        /**
         * information about nodes is stored in array $nodes (array of arrays)
         * $nodes[$nodeId] returns an array, say, $node which
@@ -134,6 +133,7 @@
                echo "truncating = " . ( $time4 - $time3 ) . " sec \n";
 
        }
+
        /**
         * method calculates covering for current
         * revision (sets property $cCovering)
@@ -190,6 +190,7 @@
                $this->cCovering = $result;
                return $arrayOfLeavesId;
        }
+
        /**
         * given string s of length N method
         * returns leaf id that string path
@@ -309,6 +310,7 @@
                        return null;
                }
        }
+
        /**
         * given covering for current revision (property $cCovering)
         * method updates all covering labels in the tree
@@ -336,6 +338,7 @@
                        $this->setCoveringLabel( $leafId, $labels );
                }
        }
+
        /**
         * method sets covering labels $covLabels
         * to the leaf with node id $leafId
@@ -361,7 +364,6 @@
                $this->nodes[$newNodeId] = $newNode;
                return $newNodeId;
        }
-
 
        protected function addEdge( $srcNodeId, $destNodeId, $tokens ) {
                // is there edges with the same source node?
@@ -426,6 +428,7 @@
                $this->addEdge( $middleNodeId, $eDestNodeIdOld, $secondPartOfe 
);
                return $middleNodeId;
        }
+
        /**
         * method deletes nodes and edges that were
         * visited more than "threshold" revisions ago
@@ -460,6 +463,7 @@
                        unset( $this->nodes[$nodeId] );
                }
        }
+
        /**
         * calculates threshold for truncating nodes.
         * all nodes that were visited more than $threshold
@@ -536,6 +540,7 @@
                return array_slice( $inputArray, $startIdx,
                                                   $endIdx - $startIdx + 1 );
        }
+
        /**
         * returns lenght of common prefix
         * between two strings (array of tokens)
@@ -632,7 +637,6 @@
                // to load tree with parameters
        }
 
-
        /**
         * dumps tree to json
         */
@@ -675,9 +679,11 @@
                }
                return json_encode( $result );
        }
+
        public function testGetNodes() {
                return $this->nodes;
        }
+
        public function testGetEdges() {
                return $this->edges;
        }
diff --git a/blamemaps.php b/blamemaps.php
index 598ad6f..9b2ba75 100644
--- a/blamemaps.php
+++ b/blamemaps.php
@@ -13,6 +13,10 @@
 $wgHooks['RevisionInsertComplete'][] = 'putJobInQueue';
 $wgHooks['LoadExtensionSchemaUpdates'][] = 'createTable';
 
+/**
+ * @param DatabaseUpdater $updater
+ * @return bool
+ */
 function createTable( DatabaseUpdater $updater ) {
        $base = __DIR__;
        $updater->addExtensionUpdate( array( 'addTable', 'bm_jobQueue',
@@ -24,19 +28,27 @@
        return true;
 }
 
-function putJobInQueue ( &$revision, $data, $flags ) {
+/**
+ * @param Revision $revision
+ * @param $data
+ * @param $flags
+ * @return bool
+ */
+function putJobInQueue( &$revision, $data, $flags ) {
        // if user did not change revision then just quit
        if ( $revision === null ) {
-               return True;
+               return true;
        }
        $article_id = $revision->getPage();
        $revision_id = $revision->getID();
        // put job in the queue
        $dbw = wfGetDB( DB_MASTER );
        $dbw->insert( 'bm_jobQueue',
-                                array( 'article_id' => $article_id,
-                                               'revision_id' => $revision_id ),
-                                $fname,
-                                'IGNORE' );
-       return True;
+                               array( 'article_id' => $article_id,
+                                               'revision_id' => $revision_id
+                               ),
+                               __METHOD__,
+                               'IGNORE'
+       );
+       return true;
 }
diff --git a/createTable.sql b/createTable.sql
index f31f7bb..03d7191 100644
--- a/createTable.sql
+++ b/createTable.sql
@@ -1,21 +1,21 @@
-CREATE TABLE IF NOT EXISTS bm_jobQueue(
+CREATE TABLE IF NOT EXISTS /*_*/bm_jobQueue(
   article_id integer unsigned,
   revision_id integer unsigned,
   PRIMARY KEY (article_id, revision)
-);
+) /*$wgDBTableOptions*/;
 
-CREATE TABLE IF NOT EXISTS bm_triesJsons(
+CREATE TABLE IF NOT EXISTS /*_*/bm_triesJsons(
   article_id integer unsigned,
   revision_id integer unsigned,
   timestamp char(22),
   tree_json mediumtext,
   PRIMARY KEY (article_id)
-);
+) /*$wgDBTableOptions*/;
 
-CREATE TABLE IF NOT EXISTS bm_coveringsJsons(
+CREATE TABLE IF NOT EXISTS /*_*/bm_coveringsJsons(
   article_id integer unsigned,
   revision_id integer unsigned,
   timestamp char(22),
   covering_json mediumtext,
   PRIMARY KEY (article_id, revision)
-);
+) /*$wgDBTableOptions*/;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic62569319e385dcb4b319f75d4bc632e835bd6c5
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/BlameMaps
Gerrit-Branch: master
Gerrit-Owner: Reedy <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to