Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
UserMergeHooks
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 2
20
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 onUserMergeAccountFields
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3// phpcs:disable MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName
4
5namespace MediaWiki\Extension\WikiLove;
6
7use MediaWiki\Config\Config;
8use MediaWiki\Extension\UserMerge\Hooks\AccountFieldsHook;
9use Wikimedia\Rdbms\ILoadBalancer;
10
11/**
12 * All hooks from the UserMerge extension which is optional to use with this extension.
13 *
14 * @file
15 * @ingroup Extensions
16 */
17
18class UserMergeHooks implements AccountFieldsHook {
19    private Config $config;
20    private ILoadBalancer $loadBalancer;
21
22    /**
23     * @param Config $config
24     * @param ILoadBalancer $loadBalancer
25     */
26    public function __construct(
27        Config $config,
28        ILoadBalancer $loadBalancer
29    ) {
30        $this->config = $config;
31        $this->loadBalancer = $loadBalancer;
32    }
33
34    /**
35     * Tables that Extension:UserMerge needs to update
36     *
37     * @param array &$updateFields
38     */
39    public function onUserMergeAccountFields( array &$updateFields ): void {
40        $dbr = $this->loadBalancer->getMaintenanceConnectionRef( DB_REPLICA );
41        // FIXME HACK: The extension never actually required the 'wikilove_log' table
42        // and would suppress db errors if it didn't exist
43        if (
44            $this->config->get( 'WikiLoveLogging' ) &&
45            $dbr->tableExists( 'wikilove_log', __METHOD__ )
46        ) {
47            $updateFields[] = [ 'wikilove_log', 'wll_sender' ];
48            $updateFields[] = [ 'wikilove_log', 'wll_receiver' ];
49        }
50    }
51
52}