+ /**
+ * Retrieves the restrictions based on the query result.
+ *
+ * @param IResultWrapper $result
+ * @param int $limit
+ *
+ * @return array
+ */
+ private static function getRestrictionData( IResultWrapper $result, $limit ) {
+ $partialIds = [];
+ $count = 0;
+ foreach ( $result as $row ) {
+ if ( ++$count <= $limit && !$row->ipb_sitewide ) {
+ $partialIds[] = (int)$row->ipb_id;
+ }
+ }
+
+ $restrictions = BlockRestriction::loadByBlockId( $partialIds );
+
+ $data = [];
+ $keys = [
+ 'page' => 'pages',
+ 'ns' => 'namespaces',
+ ];
+ foreach ( $restrictions as $restriction ) {
+ $key = $keys[$restriction->getType()];
+ $id = $restriction->getBlockId();
+ switch ( $restriction->getType() ) {
+ case 'page':
+ $value = [ 'id' => $restriction->getValue() ];
+ self::addTitleInfo( $value, $restriction->getTitle() );
+ break;
+ default:
+ $value = $restriction->getValue();
+ }
+
+ if ( !isset( $data[$id][$key] ) ) {
+ $data[$id][$key] = [];
+ ApiResult::setIndexedTagName( $data[$id][$key], $restriction->getType() );
+ }
+ $data[$id][$key][] = $value;
+ }
+
+ return $data;
+ }
+