Bsitu has uploaded a new change for review.

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


Change subject: Remove invalid maintenance scripts
......................................................................

Remove invalid maintenance scripts

These maintenance scripts have never run before and will never run in
the future.  We decided that we don't understand user_properties table
enough to mess with it, and we went with another simpler approach instead

Change-Id: Ic33375a579267aca40a54d74f839fee042afc24f
---
D maintenance/copyExistingEmailPreference.php
D maintenance/rebuildUpdatedUserCache.php
D maintenance/setEmailOptionTemp.php
3 files changed, 0 insertions(+), 215 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo 
refs/changes/56/71856/1

diff --git a/maintenance/copyExistingEmailPreference.php 
b/maintenance/copyExistingEmailPreference.php
deleted file mode 100644
index 3939583..0000000
--- a/maintenance/copyExistingEmailPreference.php
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-/**
- * Copy existing users preference on whether to get email talk page 
notifications
- * to the new notification system
- *
- * @ingroup Maintenance
- */
-require_once ( getenv( 'MW_INSTALL_PATH' ) !== false
-       ? getenv( 'MW_INSTALL_PATH' ) . '/maintenance/Maintenance.php'
-       : dirname( __FILE__ ) . '/../../../maintenance/Maintenance.php' );
-
-/**
- * Copy user's notification pref from the old talk page email notification 
setting to the new one
- *
- * @ingroup Maintenance
- */
-class CopyExistingEmailPreference extends Maintenance {
-
-       public function __construct() {
-               parent::__construct();
-               $this->mDescription = "Script for install time copying of users 
who have opted out of talk page emails";
-               $this->addOption( 'batch', 'Batch size for SQL partitioning', 
false, true );
-       }
-
-       public function execute() {
-               $dbw = $this->getDB( DB_MASTER );
-
-               if( $this->hasOption( 'batch' ) ) {
-                       $batch = $this->getOption( 'batch' );
-               } else {
-                       $batch = 100;
-               }
-
-               // count the number of user who have opted out under the old 
system.
-               // DatabaseBase::query does not return rows affected
-               $users = $dbw->selectField( 'user_properties', 'COUNT(*)', 
array( "up_property='enotifusertalkpages'" ), __METHOD__ );
-
-               $total = 0;
-
-               // risks missing people if extra users opt out between script 
starting and finishing
-               for( $i = 0; $i<$users;  $i+=$batch ) {
-                       $sql = "INSERT IGNORE INTO user_properties
-SELECT up_user, 'echo-subscriptions-email-edit-user-talk', up_value
-FROM user_properties
-WHERE up_property = 'enotifusertalkpages'
-ORDER BY up_user LIMIT $batch OFFSET $total";
-
-                       $res = $dbw->query(
-                               $sql,
-                               __METHOD__, // caller
-                               true // ignore errors
-                       );
-
-                       $total += $batch;
-
-                       if( $total < $users ) {
-                               $this->output( "Total Updated: $total\n" );
-                       }
-                       wfWaitForSlaves();
-               }
-               $this->output( "Done. Final total: $users\n" );
-       }
-}
-
-$maintClass = 'CopyExistingEmailPreference'; // Tells it to run the class
-require_once( RUN_MAINTENANCE_IF_MAIN );
diff --git a/maintenance/rebuildUpdatedUserCache.php 
b/maintenance/rebuildUpdatedUserCache.php
deleted file mode 100755
index dff5d73..0000000
--- a/maintenance/rebuildUpdatedUserCache.php
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-/**
- * @ingroup Maintenance
- */
-require_once ( getenv( 'MW_INSTALL_PATH' ) !== false
-       ? getenv( 'MW_INSTALL_PATH' ) . '/maintenance/Maintenance.php'
-       : dirname( __FILE__ ) . '/../../../maintenance/Maintenance.php' );
-
-/**
- * Rebuild cache for users updated by CopyExistingEmailPreference
- *
- * @ingroup Maintenance
- */
-class RebuildUpdatedUserCache extends Maintenance {
-
-       public function __construct() {
-               parent::__construct();
-               $this->mDescription = "Script for clearing user cache for 
updated users";
-               $this->addOption( 'batch', 'Batch size', false, true );
-       }
-
-       public function execute() {
-               global $wgMemc;
-
-               if( $this->hasOption( 'batch' ) ) {
-                       $batch = $this->getOption( 'batch' );
-               } else {
-                       $batch = 100;
-               }
-
-               $begin = time();
-               $dbr = $this->getDB( DB_SLAVE );
-               $updated = 0;
-               $lastUserID = 0;
-
-               while ( true ) {
-                       $res = $dbr->select(
-                               'user_properties', // table
-                               array( 'up_user' ), // fields
-                               array(
-                                       'up_property' => 'enotifusertalkpages',
-                                       'up_user > ' . $dbr->addQuotes( 
$lastUserID ),
-                               ), // conditions
-                               __METHOD__, // caller
-                               array( 'LIMIT' => $batch, 'ORDER BY' => 
'up_user' ) // options
-                       );
-                       if ( !$res->numRows() ) {
-                               break;
-                       }
-                       foreach ( $res as $row ) {
-                               $lastUserID = $row->up_user;
-                               $user = User::newFromId( $row->up_user );
-                               $user->invalidateCache();
-                               $updated++;
-                       }
-                       $this->output( "Updated: $updated; Last ID processed: 
$lastUserID\n" );
-                       wfWaitForSlaves();
-               }
-
-               $end = time();
-               $duration = $end - $begin;
-               $this->output( "Done. Elapsed seconds: $duration\n" );
-       }
-}
-
-$maintClass = 'RebuildUpdatedUserCache'; // Tells it to run the class
-require_once( RUN_MAINTENANCE_IF_MAIN );
diff --git a/maintenance/setEmailOptionTemp.php 
b/maintenance/setEmailOptionTemp.php
deleted file mode 100755
index 89600f9..0000000
--- a/maintenance/setEmailOptionTemp.php
+++ /dev/null
@@ -1,82 +0,0 @@
-<?php
-/**
- * Opt existing users out of some echo notifications
- *
- * @ingroup Maintenance
- */
-require_once ( getenv( 'MW_INSTALL_PATH' ) !== false
-       ? getenv( 'MW_INSTALL_PATH' ) . '/maintenance/Maintenance.php'
-       : dirname( __FILE__ ) . '/../../../maintenance/Maintenance.php' );
-
-/**
- * Set existing user's notification prefs to be different than defaults in 
some cases.
- *
- * @ingroup Maintenance
- */
-class SetEmailOptionTemp extends Maintenance {
-
-       public function __construct() {
-               parent::__construct();
-               $this->mDescription = "Script for pre-emptively updating user 
options of users who have opted out of talk page emails";
-               $this->addOption( 'days', 'Only update users that have been 
active within this number of days (maximum 100)', true, true, 'd' );
-               $this->setBatchSize( 100 );
-       }
-
-       public function execute() {
-               $begin = time();
-               $dbr = $this->getDB( DB_SLAVE );
-
-               $total = 0;
-               $updated = 0;
-               $lastUserID = 0;
-
-               // Generate the proper timestamp to use as a threshold
-               $now = time();
-               if ( $this->getOption( 'days' ) > 100 ) {
-                       $days = 100;
-               } else {
-                       $days = $this->getOption( 'days' );
-               }
-               $seconds = $days * 86400;
-               $threshold = $now - $seconds;
-
-               while ( true ) {
-                       $res = $dbr->select(
-                               'user', // table
-                               array( 'user_id' ), // fields
-                               array(
-                                       'user_id > ' . $dbr->addQuotes( 
$lastUserID ),
-                                       'user_touched > ' . $dbr->addQuotes( 
$dbr->timestamp( $threshold ) ),
-                               ), // conditions
-                               __METHOD__, // caller
-                               array( 'LIMIT' => $this->mBatchSize, 'ORDER BY' 
=> 'user_id' ) // options
-                       );
-                       if ( !$res->numRows() ) {
-                               break;
-                       }
-                       $total += $res->numRows();
-                       foreach ( $res as $row ) {
-                               $lastUserID = $row->user_id;
-                               $user = User::newFromId( $row->user_id );
-                               // If the user has disabled 'Email me when my 
user talk page is changed'
-                               // also disable the talk page email 
notification in Echo.
-                               if ( !$user->getOption( 'enotifusertalkpages' )
-                                       && is_null( $user->getOption( 
'echo-subscriptions-email-edit-user-talk' ) )
-                               ) {
-                                       $user->setOption( 
'echo-subscriptions-email-edit-user-talk', 0 );
-                                       $user->saveSettings();
-                                       $updated++;
-                               }
-                       }
-                       $this->output( "Processed: $total; Updated: $updated; 
Last ID processed: $lastUserID\n" );
-                       wfWaitForSlaves();
-               }
-
-               $end = time();
-               $duration = $end - $begin;
-               $this->output( "Done. Elapsed seconds: $duration\n" );
-       }
-}
-
-$maintClass = 'SetEmailOptionTemp'; // Tells it to run the class
-require_once( RUN_MAINTENANCE_IF_MAIN );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic33375a579267aca40a54d74f839fee042afc24f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Bsitu <[email protected]>

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

Reply via email to