Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
LocalSerialProvider
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getDB
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getTableName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace MediaWiki\User\TempUser;
4
5use Wikimedia\Rdbms\ILBFactory;
6
7/**
8 * A serial provider which allocates IDs from the local database, or from a
9 * shared database if $wgSharedDB is used. It is "local" in the sense that it
10 * uses the same DB connection as the local wiki.
11 *
12 * @since 1.39
13 */
14class LocalSerialProvider extends DBSerialProvider {
15    /**
16     * @param array $config
17     *   - numShards (int, default 1): A small integer. This can be set to a
18     *     value greater than 1 to avoid acquiring a global lock when
19     *     allocating IDs, at the expense of making the IDs be non-monotonic.
20     * @param ILBFactory $lbf
21     */
22    public function __construct(
23        array $config,
24        private readonly ILBFactory $lbf,
25    ) {
26        parent::__construct( $config );
27    }
28
29    /** @inheritDoc */
30    protected function getDB() {
31        // So that startAtomic() will start a commit, reducing lock time.
32        // Without this flag, the transaction will be open until the start
33        // of request shutdown. This could be omitted to reduce the
34        // connection overhead, with numShards tuned upwards to compensate.
35        return $this->lbf->getAutoCommitPrimaryConnection();
36    }
37
38    /** @inheritDoc */
39    protected function getTableName() {
40        return 'user_autocreate_serial';
41    }
42}