X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fblock%2FBlockRestriction.php;h=2e8752e45018c2b8fb7122c4aa0be2ec20a5157c;hb=1f46e0e6dc36a8f351f3b71a324f8ac0e6f19adc;hp=b5574f9fe8846b27429f39c8023ca338ff5fc4e8;hpb=c09693a29c4d28982fe2047e1759a13a296c65e0;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/block/BlockRestriction.php b/includes/block/BlockRestriction.php index b5574f9fe8..2e8752e450 100644 --- a/includes/block/BlockRestriction.php +++ b/includes/block/BlockRestriction.php @@ -25,6 +25,7 @@ namespace MediaWiki\Block; use MediaWiki\Block\Restriction\NamespaceRestriction; use MediaWiki\Block\Restriction\PageRestriction; use MediaWiki\Block\Restriction\Restriction; +use MWException; use Wikimedia\Rdbms\IResultWrapper; use Wikimedia\Rdbms\IDatabase; @@ -51,7 +52,7 @@ class BlockRestriction { return []; } - $db = $db ?: wfGetDb( DB_REPLICA ); + $db = $db ?: wfGetDB( DB_REPLICA ); $result = $db->select( [ 'ipblocks_restrictions', 'page' ], @@ -73,7 +74,7 @@ class BlockRestriction { * @return bool */ public static function insert( array $restrictions ) { - if ( empty( $restrictions ) ) { + if ( !$restrictions ) { return false; } @@ -85,18 +86,20 @@ class BlockRestriction { $rows[] = $restriction->toRow(); } - if ( empty( $rows ) ) { + if ( !$rows ) { return false; } $dbw = wfGetDB( DB_MASTER ); - return $dbw->insert( + $dbw->insert( 'ipblocks_restrictions', $rows, __METHOD__, [ 'IGNORE' ] ); + + return true; } /** @@ -149,7 +152,6 @@ class BlockRestriction { $restrictions ); - // Nothing to remove. if ( empty( $restrictionsToRemove ) ) { continue; } @@ -181,7 +183,7 @@ class BlockRestriction { $parentBlockId = (int)$parentBlockId; - $db = wfGetDb( DB_MASTER ); + $db = wfGetDB( DB_MASTER ); $db->startAtomic( __METHOD__ );