use Wikimedia\Rdbms\Database;
use Wikimedia\Rdbms\IDatabase;
-use MediaWiki\Block\BlockRestriction;
+use MediaWiki\Block\BlockRestrictionStore;
use MediaWiki\Block\Restriction\Restriction;
use MediaWiki\Block\Restriction\NamespaceRestriction;
use MediaWiki\Block\Restriction\PageRestriction;
&& $this->isSitewide() == $block->isSitewide()
// Block::getRestrictions() may perform a database query, so keep it at
// the end.
- && BlockRestriction::equals( $this->getRestrictions(), $block->getRestrictions() )
+ && $this->getBlockRestrictionStore()->equals(
+ $this->getRestrictions(), $block->getRestrictions()
+ )
);
}
$dbw = wfGetDB( DB_MASTER );
- BlockRestriction::deleteByParentBlockId( $this->getId() );
+ $this->getBlockRestrictionStore()->deleteByParentBlockId( $this->getId() );
$dbw->delete( 'ipblocks', [ 'ipb_parent_block_id' => $this->getId() ], __METHOD__ );
- BlockRestriction::deleteByBlockId( $this->getId() );
+ $this->getBlockRestrictionStore()->deleteByBlockId( $this->getId() );
$dbw->delete( 'ipblocks', [ 'ipb_id' => $this->getId() ], __METHOD__ );
return $dbw->affectedRows() > 0;
if ( $affected ) {
$this->setId( $dbw->insertId() );
if ( $this->restrictions ) {
- BlockRestriction::insert( $this->restrictions );
+ $this->getBlockRestrictionStore()->insert( $this->restrictions );
}
}
);
if ( $ids ) {
$dbw->delete( 'ipblocks', [ 'ipb_id' => $ids ], __METHOD__ );
- BlockRestriction::deleteByBlockId( $ids );
+ $this->getBlockRestrictionStore()->deleteByBlockId( $ids );
$dbw->insert( 'ipblocks', $row, __METHOD__, [ 'IGNORE' ] );
$affected = $dbw->affectedRows();
$this->setId( $dbw->insertId() );
if ( $this->restrictions ) {
- BlockRestriction::insert( $this->restrictions );
+ $this->getBlockRestrictionStore()->insert( $this->restrictions );
}
}
}
if ( $this->restrictions !== null ) {
// An empty array should remove all of the restrictions.
if ( empty( $this->restrictions ) ) {
- $success = BlockRestriction::deleteByBlockId( $this->getId() );
+ $success = $this->getBlockRestrictionStore()->deleteByBlockId( $this->getId() );
} else {
- $success = BlockRestriction::update( $this->restrictions );
+ $success = $this->getBlockRestrictionStore()->update( $this->restrictions );
}
// Update the result. The first false is the result, otherwise, true.
$result = $result && $success;
// Only update the restrictions if they have been modified.
if ( $this->restrictions !== null ) {
- BlockRestriction::updateByParentBlockId( $this->getId(), $this->restrictions );
+ $this->getBlockRestrictionStore()->updateByParentBlockId( $this->getId(), $this->restrictions );
}
} else {
// autoblock no longer required, delete corresponding autoblock(s)
- BlockRestriction::deleteByParentBlockId( $this->getId() );
+ $this->getBlockRestrictionStore()->deleteByParentBlockId( $this->getId() );
$dbw->delete(
'ipblocks',
[ 'ipb_parent_block_id' => $this->getId() ],
$this->mId = (int)$blockId;
if ( is_array( $this->restrictions ) ) {
- $this->restrictions = BlockRestriction::setBlockId( $blockId, $this->restrictions );
+ $this->restrictions = $this->getBlockRestrictionStore()->setBlockId(
+ $blockId, $this->restrictions
+ );
}
return $this;
$fname
);
if ( $ids ) {
- BlockRestriction::deleteByBlockId( $ids );
+ $blockRestrictionStore = MediaWikiServices::getInstance()->getBlockRestrictionStore();
+ $blockRestrictionStore->deleteByBlockId( $ids );
+
$dbw->delete( 'ipblocks', [ 'ipb_id' => $ids ], $fname );
}
}
if ( !$this->mId ) {
return [];
}
- $this->restrictions = BlockRestriction::loadByBlockId( $this->mId );
+ $this->restrictions = $this->getBlockRestrictionStore()->loadByBlockId( $this->mId );
}
return $this->restrictions;
}
}
+ /**
+ * Get a BlockRestrictionStore instance
+ *
+ * @return BlockRestrictionStore
+ */
+ private function getBlockRestrictionStore() : BlockRestrictionStore {
+ return MediaWikiServices::getInstance()->getBlockRestrictionStore();
+ }
}