NameTableStore: ensure consistency upon rollback.
authordaniel <dkinzler@wikimedia.org>
Tue, 4 Jun 2019 10:14:43 +0000 (12:14 +0200)
committerReedy <reedy@wikimedia.org>
Thu, 10 Oct 2019 22:11:59 +0000 (22:11 +0000)
commit56f171b9586f56bd4f9eb4b0bd25859d56561c1e
tree96adb956391e4eef7056814a80d7d6afdef9f180
parentdbba623b8bf23119add41931ed858a1fe489aa57
NameTableStore: ensure consistency upon rollback.

This ensures consistent behavior when an ID for a name is first acquired
within a transaction that is rolled back. The documentation for acquireId
now reads:

@note If called within a transaction, there is a chance for the acquired ID to be lost
if the transaction is rolled back. A best effort is made to re-insert the mapping
after a rollback, and consistency of the cache with the database table is ensured
by re-loading the map after a failed transaction. However, there is no guarantee
that an ID returned by this method is valid outside the transaction in which it
was produced. This means that calling code should not retain the return value beyond
the scope of a transaction, but rather call acquireId() again after the transaction
is complete. In some rare cases, this may produce an ID different from the first call.

Bug: T224949
Change-Id: I6d05e4112a649675bfb9083cab2d1bbe394e65b3
(cherry picked from commit 135673b98eccc43528ce0dcc0ef61ed44b932471)
includes/Storage/NameTableStore.php
maintenance/populateContentTables.php
tests/phpunit/includes/Storage/NameTableStoreTest.php