Page MenuHomeMiraheze
Paste P133

(An Untitled Masterwork)
ActivePublic

Authored by Paladox on Nov 2 2018, 21:46.
Tags
None
Referenced Files
F862112:
Nov 2 2018, 23:37
F862086:
Nov 2 2018, 21:46
Subscribers
None
<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
* @ingroup Maintenance
* @author Southparkfan
* @author John Lewis
* @author Paladox
* @version 1.0
*/
require_once( __DIR__ . '/../../../maintenance/Maintenance.php' );
class AssignImportedEdits extends Maintenance {
public function __construct() {
parent::__construct();
$this->mDescription = "Re assigns imported edits for users";
$this->addOption( 'user', 'Username you want edits to be assigned to.', false, true );
}
public function execute() {
global $wgDBname;
$dbw = wfGetDB( DB_MASTER );
$dbw->selectDB( $wgDBname );
$res = $dbw->select(
'revision',
'rev_user_text',
array(),
__METHOD__
);
if ( !$res || !is_object( $res ) ) {
throw new MWException( '$res was not set to a valid array.' );
}
foreach ( $res as $row ) {
$user = $this->getOption( 'user' );
if ( $user ) {
$nameIsValid = User::newFromName( $user )->getId();
$name = 'imported>' . $user;
} else {
$user = str_replace('imported>', '', $row->rev_user_text);
$nameIsValid = User::newFromName( $user );
$name = 'imported>' . $user;
}
if ( $nameIsValid && $name === $row->rev_user_text ) {
$DBname = $row->rev_user_text;
$this->output( "test {$DBname}\n");
}
/*
$dbw->selectDB( $wgCreateWikiGlobalWiki );
$res = $dbw->selectRow(
'logging',
'log_timestamp',
array(
'log_action' => 'createwiki',
'log_params' => serialize( array( '4::wiki' => $DBname ) )
),
__METHOD__,
array( // Sometimes a wiki might have been created multiple times.
'ORDER BY' => 'log_timestamp DESC'
)
);
$dbw->selectDB( $wgCreateWikiDatabase );
if ( !isset( $res ) || !isset( $res->log_timestamp ) ) {
$this->output( "ERROR: couldn't determine when {$DBname} was created!\n" );
continue;
}
$dbw->update(
'cw_wikis',
[
'wiki_creation' => $res->log_timestamp,
],
[
'wiki_dbname' => $DBname
],
__METHOD__
);*/
//$this->output( "test {$DBname}\n");
}
}
}
$maintClass = 'AssignImportedEdits';
require_once RUN_MAINTENANCE_IF_MAIN;