Merge "Improve docs for Title::getInternalURL/getCanonicalURL"
[lhc/web/wiklou.git] / includes / block / BlockRestriction.php
index b5574f9..2e8752e 100644 (file)
@@ -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__ );