Kaldari has uploaded a new change for review.
https://gerrit.wikimedia.org/r/60689
Change subject: Maintainence script for changing user options for existing users
......................................................................
Maintainence script for changing user options for existing users
Change-Id: I89db959e1ce99d29f00ccb93ac5b7ca84825f111
---
A maintenance/setEchoUserOptions.php
1 file changed, 74 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo
refs/changes/89/60689/1
diff --git a/maintenance/setEchoUserOptions.php
b/maintenance/setEchoUserOptions.php
new file mode 100644
index 0000000..8d2db8e
--- /dev/null
+++ b/maintenance/setEchoUserOptions.php
@@ -0,0 +1,74 @@
+<?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 setEchoUserOptions extends Maintenance {
+
+ public function execute() {
+ $dbw = wfGetDB( DB_MASTER );
+
+ $batchSize = 100;
+ $total = 0;
+ $lastUserID = 0;
+
+ while ( true ) {
+ $res = $dbw->select(
+ 'user_properties', // table
+ array( 'up_user' ), // fields
+ array( "up_user > $lastUserID" ), // conditions
+ __METHOD__, // caller
+ array( 'LIMIT' => $batchSize ) // options
+ );
+ if ( !$res->numRows() ) {
+ $dbw->commit();
+ break;
+ }
+ $total += $res->numRows();
+
+ $ids = array();
+ foreach ( $res as $row ) {
+ $ids[] = $row->up_user;
+ }
+ $lastUserID = max( $ids );
+
+ foreach ( $ids as $id ) {
+ $user = User::newFromId( $id );
+ // Skip anonymous users
+ if ( !$user->isLoggedIn() ) {
+ continue;
+ }
+ // 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', 0
) ) {
+ $user->setOption(
'echo-subscriptions-email-edit-user-talk ', 0 );
+ }
+ $user->setOption(
'echo-subscriptions-web-reverted', 1 );
+ $user->setOption(
'echo-subscriptions-web-article-linked', 1 );
+ $user->setOption(
'echo-subscriptions-email-mention', 0 );
+ $user->setOption(
'echo-subscriptions-email-page-review', 0 );
+ $user->setOption(
'echo-subscriptions-email-edit-thank', 0 );
+ $user->setOption(
'echo-subscriptions-email-article-linked', 0 );
+ $user->saveSettings();
+ }
+
+ echo "$total\n";
+
+ wfWaitForSlaves();
+ }
+ echo "Done\n";
+ }
+}
+
+$maintClass = 'setEchoUserOptions'; // Tells it to run the class
+require_once( RUN_MAINTENANCE_IF_MAIN );
--
To view, visit https://gerrit.wikimedia.org/r/60689
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I89db959e1ce99d29f00ccb93ac5b7ca84825f111
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Kaldari <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits