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    public function __construct(
23        Config $config,
24        ILoadBalancer $loadBalancer
25    ) {
26        $this->config = $config;
27        $this->loadBalancer = $loadBalancer;
28    }
29
30    /**
31     * Tables that Extension:UserMerge needs to update
32     */
33    public function onUserMergeAccountFields( array &$updateFields ): void {
34        $dbr = $this->loadBalancer->getMaintenanceConnectionRef( DB_REPLICA );
35        // FIXME HACK: The extension never actually required the 'wikilove_log' table
36        // and would suppress db errors if it didn't exist
37        if (
38            $this->config->get( 'WikiLoveLogging' ) &&
39            $dbr->tableExists( 'wikilove_log', __METHOD__ )
40        ) {
41            $updateFields[] = [ 'wikilove_log', 'wll_sender' ];
42            $updateFields[] = [ 'wikilove_log', 'wll_receiver' ];
43        }
44    }
45
46}