Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 30
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
GlobalRenameUserLogger
0.00% covered (danger)
0.00%
0 / 30
0.00% covered (danger)
0.00%
0 / 3
12
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 log
0.00% covered (danger)
0.00%
0 / 15
0.00% covered (danger)
0.00%
0 / 1
2
 logPromotion
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace MediaWiki\Extension\CentralAuth\GlobalRename;
4
5use ManualLogEntry;
6use MediaWiki\SpecialPage\SpecialPage;
7use MediaWiki\User\UserIdentity;
8
9/**
10 * Log a global rename into the local log
11 *
12 * @license GPL-2.0-or-later
13 * @author Marius Hoch < hoo@online.de >
14 */
15class GlobalRenameUserLogger {
16    /**
17     * @var UserIdentity
18     */
19    private $performingUser;
20
21    /**
22     * @param UserIdentity $performingUser
23     */
24    public function __construct( UserIdentity $performingUser ) {
25        $this->performingUser = $performingUser;
26    }
27
28    /**
29     * @param string $oldName
30     * @param string $newName
31     * @param array $options
32     */
33    public function log( $oldName, $newName, $options ) {
34        $logEntry = new ManualLogEntry( 'gblrename', 'rename' );
35        $logEntry->setPerformer( $this->performingUser );
36        $logEntry->setTarget( SpecialPage::getTitleFor( 'CentralAuth', $newName ) );
37        $logEntry->setComment( $options['reason'] );
38        $logEntry->setParameters( [
39            '4::olduser' => $oldName,
40            '5::newuser' => $newName,
41            'movepages' => $options['movepages'],
42            'suppressredirects' => $options['suppressredirects'],
43        ] );
44
45        $logEntry->setRelations( [
46            'oldname' => $oldName,
47        ] );
48
49        $logid = $logEntry->insert();
50        $logEntry->publish( $logid );
51    }
52
53    /**
54     * Log the promotion of a local unattached to a global
55     *
56     * @param string $oldName
57     * @param string $wiki
58     * @param string $newName
59     * @param string $reason
60     */
61    public function logPromotion( $oldName, $wiki, $newName, $reason ) {
62        $logEntry = new ManualLogEntry( 'gblrename', 'promote' );
63        $logEntry->setPerformer( $this->performingUser );
64        $logEntry->setTarget( SpecialPage::getTitleFor( 'CentralAuth', $newName ) );
65        $logEntry->setComment( $reason );
66        $logEntry->setParameters( [
67            '4::olduser' => $oldName,
68            '5::newuser' => $newName,
69            '6::oldwiki' => $wiki,
70        ] );
71
72        $logEntry->setRelations( [
73            'oldname' => $oldName,
74        ] );
75
76        $logid = $logEntry->insert();
77        $logEntry->publish( $logid );
78    }
79}