Wikibase
MediaWiki Wikibase extension
|
Unique Id generator implemented using an SQL table and an UPSERT query. More...
Public Member Functions | |
__construct (RepoDomainDb $db, array $reservedIds=[], $separateDbConnection=false) | |
getNewId ( $type) | |
Private Member Functions | |
idIsReserved ( $type, $id) | |
generateNewId (IDatabase $database, $type) | |
Generates and returns a new ID. | |
upsertId (IDatabase $database, $type) | |
Private Attributes | |
$db | |
$reservedIds | |
const | MAX_ATTEMPTS = 10 |
$separateDbConnection | |
Unique Id generator implemented using an SQL table and an UPSERT query.
The table needs to have the fields id_value and id_type.
The UPSERT approach was created in https://phabricator.wikimedia.org/T194299 as wikidata.org was having issues with the old SqlIdGenerator.
LAST_INSERT_ID from mysql is used in this class, which means that this IdGenerator can only be used with MySQL. This class depends on the upsert implementation within the RDBMS library for different DB backends.
Wikibase\Repo\Store\Sql\UpsertSqlIdGenerator::__construct | ( | RepoDomainDb | $db, |
array | $reservedIds = [], | ||
$separateDbConnection = false ) |
RepoDomainDb | $db | |
int[][] | $reservedIds | |
bool | $separateDbConnection |
|
private |
Generates and returns a new ID.
IDatabase | $database | |
string | $type |
RuntimeException |
Wikibase\Repo\Store\Sql\UpsertSqlIdGenerator::getNewId | ( | $type | ) |
string | $type | normally is content model id (e.g. wikibase-item or wikibase-property) |
RuntimeException |
Implements Wikibase\Repo\Store\IdGenerator.
|
private |
|
private |
IDatabase | $database | |
string | $type |
|
private |
|
private |
|
private |
|
private |