2012-06-06 06:28:44 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
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
|
2012-08-30 16:04:39 +00:00
|
|
|
while ( $continue ) {
|
2012-06-06 06:28:44 +00:00
|
|
|
$uRes = $dbr->select( 'user',
|
|
|
|
'*',
|
2012-08-30 16:04:39 +00:00
|
|
|
array( 'user_id > ' . $dbr->addQuotes( $uid ) ),
|
2012-06-06 06:28:44 +00:00
|
|
|
__METHOD__,
|
2012-08-30 16:04:39 +00:00
|
|
|
array( 'LIMIT' => 500 )
|
2012-06-06 06:28:44 +00:00
|
|
|
);
|
|
|
|
|
2012-08-31 21:50:46 +00:00
|
|
|
foreach ( $uRes as $uRow ) {
|
2012-06-06 06:28:44 +00:00
|
|
|
$user = User::newFromRow( $uRow );
|
2012-08-30 16:04:39 +00:00
|
|
|
$wlRes = $dbr->select( 'watchlist',
|
2012-08-31 21:50:46 +00:00
|
|
|
array( 'wl_namespace', 'wl_title' ),
|
2012-06-06 06:28:44 +00:00
|
|
|
array( 'wl_user' => $uRow->user_id ),
|
|
|
|
__METHOD__
|
|
|
|
);
|
|
|
|
|
2012-08-31 21:50:46 +00:00
|
|
|
foreach ( $wlRes as $wlRow ) {
|
2012-06-06 06:28:44 +00:00
|
|
|
$title = Title::makeTitleSafe( $wlRow->wl_namespace, $wlRow->wl_title );
|
2012-08-30 16:04:39 +00:00
|
|
|
$subscription = new EchoSubscription( $user, 'edit', $title );
|
|
|
|
$subscription->enableNotification( 'notify' );
|
2012-06-06 06:28:44 +00:00
|
|
|
$subscription->save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$maintClass = "EchoConvertWatchlists";
|
2012-08-30 16:04:39 +00:00
|
|
|
require_once( RUN_MAINTENANCE_IF_MAIN );
|