Add services and utilities for automatic creation of temporary user accounts on page save, in order to avoid exposing the user's IP address. * Add $wgAutoCreateTempUser, for configuring the system * Add TempUserConfig service, which interprets the config. * Add TempUserCreator service, which creates users during page save as requested by EditPage. With proxy methods to TempUserConfig for convenience. * Add table user_autocreate_serial. Table creation is necessary before the feature is enabled but is not necessary before deployment of this commit. Bug: T300263 Change-Id: Ib14a352490fc42039106523118e8d021844e3dfb
46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\User\TempUser;
|
|
|
|
use Wikimedia\Rdbms\ILoadBalancer;
|
|
|
|
/**
|
|
* A serial provider which allocates IDs from the local database, or from a
|
|
* shared database if $wgSharedDB is used. It is "local" in the sense that it
|
|
* uses the same DB connection as the local wiki.
|
|
*
|
|
* @since 1.39
|
|
*/
|
|
class LocalSerialProvider extends DBSerialProvider {
|
|
/** @var ILoadBalancer */
|
|
private $lb;
|
|
|
|
/**
|
|
* @param array $config
|
|
* - numShards (int, default 1): A small integer. This can be set to a
|
|
* value greater than 1 to avoid acquiring a global lock when
|
|
* allocating IDs, at the expense of making the IDs be non-monotonic.
|
|
* @param ILoadBalancer $lb
|
|
*/
|
|
public function __construct( $config, ILoadBalancer $lb ) {
|
|
parent::__construct( $config );
|
|
$this->lb = $lb;
|
|
}
|
|
|
|
protected function getDB() {
|
|
return $this->lb->getConnectionRef(
|
|
DB_PRIMARY,
|
|
[],
|
|
false,
|
|
// So that startAtomic() will start a commit, reducing lock time.
|
|
// Without this flag, the transaction will be open until the start
|
|
// of request shutdown. This could be omitted to reduce the
|
|
// connection overhead, with numShards tuned upwards to compensate.
|
|
ILoadBalancer::CONN_TRX_AUTOCOMMIT
|
|
);
|
|
}
|
|
|
|
protected function getTableName() {
|
|
return 'user_autocreate_serial';
|
|
}
|
|
}
|