Legoktm has uploaded a new change for review.

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

Change subject: Add script to populate log_search for global rename entries
......................................................................

Add script to populate log_search for global rename entries

Change-Id: I230707116f468c6cca3fa20b16c65c471e5bf5e5
---
A maintenance/populateGlobalRenameLogSearch.php
1 file changed, 61 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth 
refs/changes/24/174224/1

diff --git a/maintenance/populateGlobalRenameLogSearch.php 
b/maintenance/populateGlobalRenameLogSearch.php
new file mode 100644
index 0000000..932ab56
--- /dev/null
+++ b/maintenance/populateGlobalRenameLogSearch.php
@@ -0,0 +1,61 @@
+<?php
+
+$IP = getenv( 'MW_INSTALL_PATH' );
+if ( $IP === false ) {
+       $IP = __DIR__ . '/../../..';
+}
+require_once "$IP/maintenance/Maintenance.php";
+
+/**
+ * Script to back-populate log_search for global rename entries
+ */
+class PopulateGlobalRenameLogSearch extends Maintenance {
+       public function __construct() {
+               parent::__construct();
+               $this->setBatchSize( 50 );
+       }
+
+       public function execute() {
+               //$GLOBALS['wgDebugLogFile'] = 'php://stdout';
+               $dbr = wfGetDB( DB_SLAVE );
+               $rows = $dbr->select(
+                       array( 'logging', 'log_search' ),
+                       array( 'log_id', 'log_params' ),
+                       array(
+                               'log_type' => 'gblrename',
+                               'log_action' => 'rename',
+                               'ls_field IS NULL'
+                       ),
+                       __METHOD__,
+                       array(),
+                       array( 'log_search' => array( 'LEFT JOIN', 
'log_id=ls_log_id' ) )
+               );
+               $insert = array();
+               foreach ( $rows as $row ) {
+                       $params = unserialize($row->log_params);
+                       $insert[] = array(
+                               'ls_field' => 'oldname',
+                               'ls_value' => $params['4::olduser'],
+                               'ls_log_id' => $row->log_id,
+                       );
+                       if ( count( $insert ) >= $this->mBatchSize ) {
+                               $this->insert( $insert );
+                               $insert = array();
+                       }
+               }
+               if ( $insert ) {
+                       $this->insert( $insert );
+               }
+       }
+
+       private function insert( array $rows ) {
+               $count = count( $rows );
+               $this->output( "Inserting $count rows into log_search" );
+               $dbw = wfGetDB( DB_MASTER );
+               $dbw->insert( 'log_search', $rows, __METHOD__, 'IGNORE' );
+               wfWaitForSlaves();
+       }
+}
+
+$maintClass = 'PopulateGlobalRenameLogSearch';
+require_once RUN_MAINTENANCE_IF_MAIN;
\ No newline at end of file

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I230707116f468c6cca3fa20b16c65c471e5bf5e5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>

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

Reply via email to