Ppchelko has uploaded a new change for review.

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

Change subject: Added exportPageDeletions script.
......................................................................

Added exportPageDeletions script.

In order to move the deletions to RESTBase we need to run
this maintanance script across all wikis.

Change-Id: I093bde4b7ad43691e966369e47188436a379916b
---
A maintenance/exportDeletions.php
1 file changed, 73 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/58/312958/1

diff --git a/maintenance/exportDeletions.php b/maintenance/exportDeletions.php
new file mode 100644
index 0000000..a40ce69
--- /dev/null
+++ b/maintenance/exportDeletions.php
@@ -0,0 +1,73 @@
+<?php
+/**
+ * Dump revision restrictions, one JSON object per batch and line.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Maintenance
+ * @author Petr Pchelko <ppche...@wikimedia.org>
+ */
+
+require_once __DIR__ . '/Maintenance.php';
+
+/**
+ * Maintenance script to dump revision restrictions, one JSON object per batch
+ * and line.
+ *
+ * @ingroup Maintenance
+ */
+class ExportRevisionRestrictions extends Maintenance {
+
+    public function __construct() {
+        parent::__construct();
+        $this->addDescription( 'Dump page deletions, one batch at a time' );
+        $this->addOption( 'start', 'Start from this page title in alphabetical 
order.' );
+        $this->addOption( 'limit', 'Limit the batch size to this value.' );
+    }
+
+    public function execute() {
+        // Delay for replication lag
+        wfWaitForSlaves();
+
+        $start = $this->getOption( 'start' );
+        $limit = intval( $this->getOption( 'limit', 1000 ) );
+
+        do {
+            $dbr = $this->getDB( DB_SLAVE, 'vslow' );
+            $sql = "SELECT ar_title as title, MAX(ar_rev_id) as rev_id "
+                . "FROM archive ";
+
+            if ( !is_null($start) ) {
+                $sql = $sql . "WHERE ar_title > \"{$start}\" ";
+            }
+            $sql = $sql . "GROUP BY ar_title ORDER BY ar_title ASC LIMIT 
{$limit}";
+
+
+            $batchResult = $dbr->query( $sql );
+            $rows = [];
+            foreach ( $batchResult as $row ) {
+                $rows[] = $row;
+                $start = $row->title;
+            }
+            // Emit one JSON object per line.
+            $this->output( json_encode( $rows ) . "\n" );
+        } while ( count( $rows ) );
+    }
+}
+
+$maintClass = "ExportRevisionRestrictions";
+require_once RUN_MAINTENANCE_IF_MAIN;
\ No newline at end of file

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I093bde4b7ad43691e966369e47188436a379916b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ppchelko <ppche...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to