Decouple DatabaseBlock::newFromTarget from DatabaseBlock::newLoad
authorThalia <thalia.e.chan@googlemail.com>
Fri, 24 May 2019 13:02:32 +0000 (14:02 +0100)
committerThalia <thalia.e.chan@googlemail.com>
Wed, 5 Jun 2019 15:38:29 +0000 (11:38 -0400)
commita387a375a10e02fe51dda09a288abc5b031b5744
tree89060e24a0ee064ebe6e3bdb74f7f8c925fd1900
parent1b7c2372a64d338b3f39b1eaa413ea7e637d3caa
Decouple DatabaseBlock::newFromTarget from DatabaseBlock::newLoad

Before this, DatabaseBlock:newFromTarget initialises a new block and
calls DatabaseBlock::newLoad on that instance, passing through the
target and type via that instance. However, newLoad returns a brand
new block instance. This patch makes newLoad into a static method,
with the target and type passed as method parameters.

It also separates the block-choosing logic in newLoad into a separate
method, DatabaseBlock::chooseMostSpecificBlock. Doing this (1) makes
it more transparent that Block uses two different ways to choose a
block (see also Block::chooseBlock), and (2) makes it possible to
re-use newLoad to get multiple blocks.

Also, filter out any duplicate autoblocks that are found by newLoad.

Bug: T206163
Change-Id: Iefa3aaadf2954c3b86f5c691096af31de40fae6c
includes/block/DatabaseBlock.php