use MediaWiki\Block\Restriction\PageRestriction;
use MediaWiki\Block\Restriction\Restriction;
use MWException;
+use stdClass;
use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
use Wikimedia\Rdbms\ILoadBalancer;
*/
private $loadBalancer;
- /*
- * @param LoadBalancer $loadBalancer load balancer for acquiring database connections
+ /**
+ * @param ILoadBalancer $loadBalancer load balancer for acquiring database connections
*/
public function __construct( ILoadBalancer $loadBalancer ) {
$this->loadBalancer = $loadBalancer;
return [];
}
- $db = $db ?: $this->loadBalancer->getConnection( DB_REPLICA );
+ $db = $db ?: $this->loadBalancer->getConnectionRef( DB_REPLICA );
$result = $db->select(
[ 'ipblocks_restrictions', 'page' ],
return false;
}
- $dbw = $this->loadBalancer->getConnection( DB_MASTER );
+ $dbw = $this->loadBalancer->getConnectionRef( DB_MASTER );
$dbw->insert(
'ipblocks_restrictions',
* @return bool
*/
public function update( array $restrictions ) {
- $dbw = $this->loadBalancer->getConnection( DB_MASTER );
+ $dbw = $this->loadBalancer->getConnectionRef( DB_MASTER );
$dbw->startAtomic( __METHOD__ );
$parentBlockId = (int)$parentBlockId;
- $db = $this->loadBalancer->getConnection( DB_MASTER );
+ $db = $this->loadBalancer->getConnectionRef( DB_MASTER );
$db->startAtomic( __METHOD__ );
* Delete the restrictions.
*
* @since 1.33
- * @param Restriction[]|null $restrictions
+ * @param Restriction[] $restrictions
* @throws MWException
* @return bool
*/
public function delete( array $restrictions ) {
- $dbw = $this->loadBalancer->getConnection( DB_MASTER );
+ $dbw = $this->loadBalancer->getConnectionRef( DB_MASTER );
$result = true;
foreach ( $restrictions as $restriction ) {
if ( !$restriction instanceof Restriction ) {
}
/**
- * Delete the restrictions by Block ID.
+ * Delete the restrictions by block ID.
*
* @since 1.33
* @param int|array $blockId
* @return bool
*/
public function deleteByBlockId( $blockId ) {
- $dbw = $this->loadBalancer->getConnection( DB_MASTER );
+ $dbw = $this->loadBalancer->getConnectionRef( DB_MASTER );
return $dbw->delete(
'ipblocks_restrictions',
[ 'ir_ipb_id' => $blockId ],
}
/**
- * Delete the restrictions by Parent Block ID.
+ * Delete the restrictions by parent block ID.
*
* @since 1.33
* @param int|array $parentBlockId
* @return bool
*/
public function deleteByParentBlockId( $parentBlockId ) {
- $dbw = $this->loadBalancer->getConnection( DB_MASTER );
+ $dbw = $this->loadBalancer->getConnectionRef( DB_MASTER );
return $dbw->deleteJoin(
'ipblocks_restrictions',
'ipblocks',
/**
* Convert a result row from the database into a restriction object.
*
- * @param \stdClass $row
+ * @param stdClass $row
* @return Restriction|null
*/
- private function rowToRestriction( \stdClass $row ) {
+ private function rowToRestriction( stdClass $row ) {
if ( array_key_exists( (int)$row->ir_type, $this->types ) ) {
$class = $this->types[ (int)$row->ir_type ];
return call_user_func( [ $class, 'newFromRow' ], $row );