Isarra has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/89146


Change subject: Add support for tags, parentids
......................................................................

Add support for tags, parentids

Not tested.

Skippedlist and page_random also need testing.

Change-Id: Ie7b425a3abb79b580d255f36310bd996b134cf80
---
M grabText.php
1 file changed, 33 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/tools/grabbers 
refs/changes/46/89146/1

diff --git a/grabText.php b/grabText.php
index 18df187..20ac803 100755
--- a/grabText.php
+++ b/grabText.php
@@ -174,7 +174,7 @@
                        }
                }
 
-               # Print skipped lis
+               # Print skipped list
                $this->output( "\nPage IDs skipped (not found):" );
                foreach ( $skipped as $pageID ) {
                        $this->output( "$pageID\n" );
@@ -310,7 +310,7 @@
                        'prop' => 'revisions',
                        'pageids' => $pageID,
                        'rvlimit' => $rvmax,
-                       'rvprop' => 
'ids|flags|timestamp|user|userid|comment|content',
+                       'rvprop' => 
'ids|flags|timestamp|user|userid|comment|content|tags',
                        'rvdir' => 'newer',
                        'rvend' => wfTimestamp( TS_ISO_8601, $endDate )
                );
@@ -496,9 +496,11 @@
                } else {
                        $comment = '';
                }
+               $tags = $revision['tags'];
 
                $e = array(
                        'id' => $revision['revid'],
+                       'parent_id' => $revision['parentid'],
                        'page' => $page_id,
                        'text_id' => $this->storeText( $text ),
                        'comment' => $comment,
@@ -512,11 +514,12 @@
                );
 
                $dbw = wfGetDB( DB_MASTER, array(), $this->getOption( 'db', 
$wgDBname ) );
-               # $this->output( "Inserting revision {$e['id']}\n" );
+               # insert revisions
                $dbw->insert(
                        'revision',
                        array(
                                'rev_id' => $e['id'],
+                               'rev_parent_id' => $e['parentid'],
                                'rev_page' => $e['page'],
                                'rev_text_id' => $e['text_id'],
                                'rev_comment' => $e['comment'],
@@ -530,6 +533,33 @@
                        ),
                        __METHOD__
                );
+               # Insert tags, if any
+               if ( count( $tags ) ) {
+                       $tagBlob = '';
+                       foreach ( $tags as $tag ) {
+                               $dbw->insert(
+                                       'change_tags',
+                                       array(
+                                               'ct_rev_id' => $e['id'],
+                                               'ct_tag' => $tag,
+                                       ),
+                                       __METHOD__
+                               );
+                               if ( $tagBlob == '' ) {
+                                       $tagBlob = $tag;
+                               } else {
+                                       $tagBlob = "$tagBlob, $tag";
+                               }
+                       }
+                       $dbw->insert(
+                               'tag_summary',
+                               array(
+                                       'ts_rev_id' => $e['id'],
+                                       'ts_tags' => $tagBlob,
+                               ),
+                               __METHOD__
+                       );
+               }
                $dbw->commit();
 
                return array( $revision['revid'], $e['len'] );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie7b425a3abb79b580d255f36310bd996b134cf80
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/tools/grabbers
Gerrit-Branch: master
Gerrit-Owner: Isarra <[email protected]>

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

Reply via email to