mediawiki-extensions-Echo/maintenance/convertWatchlists.php
Kaldari 3ec54376a5 Setting up preferences for Echo, adding comments for some functions
Removing watchlist features that are now out of scope

Change-Id: Icbc35a4204ed89fe6c3bfdd1fb33c525ef5dc75c
2012-12-03 11:54:34 -08:00

50 lines
1.3 KiB
PHP

<?php
// This file is deprecated since Echo is currently not being used for any
// watchlist-related functionality.
require_once ( getenv( 'MW_INSTALL_PATH' ) !== false
? getenv( 'MW_INSTALL_PATH' ) . '/maintenance/Maintenance.php'
: dirname( __FILE__ ) . '/../../../maintenance/Maintenance.php' );
class EchoConvertWatchlists extends Maintenance {
public function __construct() {
parent::__construct();
$this->mDescription = "Converts MediaWiki watchlists into Echo subscriptions";
}
public function execute() {
$dbr = wfGetDB( DB_SLAVE );
$uid = 0;
$continue = true;
// Do it one user at a time
while ( $continue ) {
$uRes = $dbr->select( 'user',
'*',
array( 'user_id > ' . $dbr->addQuotes( $uid ) ),
__METHOD__,
array( 'LIMIT' => 500 )
);
foreach ( $uRes as $uRow ) {
$user = User::newFromRow( $uRow );
$wlRes = $dbr->select( 'watchlist',
array( 'wl_namespace', 'wl_title' ),
array( 'wl_user' => $uRow->user_id ),
__METHOD__
);
foreach ( $wlRes as $wlRow ) {
$title = Title::makeTitleSafe( $wlRow->wl_namespace, $wlRow->wl_title );
$subscription = new EchoSubscription( $user, 'edit', $title );
$subscription->enableNotification( 'notify' );
$subscription->save();
}
}
}
}
}
$maintClass = "EchoConvertWatchlists";
require_once( RUN_MAINTENANCE_IF_MAIN );