Index: /trunk/src/bp-core/bp-core-filters.php
===================================================================
--- /trunk/src/bp-core/bp-core-filters.php	(revision 12568)
+++ /trunk/src/bp-core/bp-core-filters.php	(revision 12569)
@@ -1169,2 +1169,17 @@
 }
 add_action( 'bp_template_include', 'bp_core_render_email_template', 12 );
+
+/**
+ * Adds BuddyPress components' slugs to the WordPress Multisite subdirectory reserved names.
+ *
+ * @since 6.0.0
+ *
+ * @param array $names The WordPress Multisite subdirectory reserved names.
+ * @return array       The WordPress & BuddyPress Multisite subdirectory reserved names.
+ */
+function bp_core_components_subdirectory_reserved_names( $names = array() ) {
+	$bp_pages = (array) buddypress()->pages;
+
+	return array_merge( $names, wp_list_pluck( $bp_pages, 'slug' ) );
+}
+add_filter( 'subdirectory_reserved_names', 'bp_core_components_subdirectory_reserved_names' );
Index: /trunk/src/bp-core/bp-core-functions.php
===================================================================
--- /trunk/src/bp-core/bp-core-functions.php	(revision 12568)
+++ /trunk/src/bp-core/bp-core-functions.php	(revision 12569)
@@ -904,17 +904,4 @@
 	$page_ids = array_merge( $new_page_ids, bp_core_get_directory_page_ids( 'all' ) );
 	bp_core_update_directory_page_ids( $page_ids );
-}
-
-/**
- * Add illegal blog names to WP so that root components will not conflict with blog names on a subdirectory installation.
- *
- * For example, it would stop someone creating a blog with the slug "groups".
- *
- * @since 1.0.0
- *
- * @todo Deprecate?
- */
-function bp_core_add_illegal_names() {
-	update_site_option( 'illegal_names', get_site_option( 'illegal_names' ), array() );
 }
 
Index: /trunk/src/bp-core/deprecated/6.0.php
===================================================================
--- /trunk/src/bp-core/deprecated/6.0.php	(revision 12568)
+++ /trunk/src/bp-core/deprecated/6.0.php	(revision 12569)
@@ -144,2 +144,16 @@
 		_deprecated_function( __FUNCTION__, '6.0' );
 	}
+
+/**
+ * Add illegal blog names to WP so that root components will not conflict with blog names on a subdirectory installation.
+ *
+ * For example, it would stop someone creating a blog with the slug "groups".
+ *
+ * @since 1.0.0
+ * @deprecated 6.0.0
+ */
+function bp_core_add_illegal_names() {
+	_deprecated_function( __FUNCTION__, '6.0' );
+
+	update_site_option( 'illegal_names', get_site_option( 'illegal_names' ), array() );
+}
Index: /trunk/tests/phpunit/testcases/core/filters.php
===================================================================
--- /trunk/tests/phpunit/testcases/core/filters.php	(revision 12569)
+++ /trunk/tests/phpunit/testcases/core/filters.php	(revision 12569)
@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * @group core
+ */
+
+class BP_Tests_Core_Filters extends BP_UnitTestCase {
+	/**
+	 * @group bp_core_components_subdirectory_reserved_names
+	 * @ticket 8187
+	 */
+	public function test_bp_core_components_subdirectory_reserved_names() {
+		if ( ! is_multisite() || is_subdomain_install() ) {
+			$this->markTestSkipped();
+		}
+
+		$u = self::factory()->user->create();
+
+		$site_data = wpmu_validate_blog_signup( 'members', 'Members', $u );
+
+		$this->assertTrue( is_wp_error( $site_data['errors'] ), 'On MS subdomain installs, a new site should not be able to use a component slug' );
+	}
+}
Index: /trunk/tests/phpunit/testcases/core/functions.php
===================================================================
--- /trunk/tests/phpunit/testcases/core/functions.php	(revision 12568)
+++ /trunk/tests/phpunit/testcases/core/functions.php	(revision 12569)
@@ -840,3 +840,47 @@
 		$bp->pages = $reset_bp_pages;
 	}
+
+	/**
+	 * @group bp_core_add_page_mappings
+	 * @ticket 8187
+	 */
+	public function test_bp_core_add_page_mappings_in_multisite_subdirectory() {
+		if ( ! is_multisite() || is_subdomain_install() ) {
+			$this->markTestSkipped();
+		}
+
+		if ( function_exists( 'wp_initialize_site' ) ) {
+			$this->setExpectedDeprecated( 'wpmu_new_blog' );
+		}
+
+		$bp = buddypress();
+		$reset_bp_pages = $bp->pages;
+		$reset_bp_active_components = $bp->active_components;
+		$reset_option = bp_get_option( 'bp-pages' );
+
+		$b = self::factory()->blog->create( array(
+			'path'   => '/newcomponent/',
+		) );
+
+		$bp->active_components['newcomponent'] = 1;
+		add_filter( 'bp_core_get_directory_page_default_titles', array( $this, 'add_newcomponent_page_title' ) );
+
+		bp_core_add_page_mappings( $bp->active_components );
+
+		remove_filter( 'bp_core_get_directory_page_default_titles', array( $this, 'add_newcomponent_page_title' ) );
+		$bp_pages = bp_get_option( 'bp-pages' );
+
+		$new_component_page_id = $bp_pages['newcomponent'];
+		$this->assertNotSame( 'newcomponent', get_post_field( 'post_name', $new_component_page_id ), 'The component slug should not conflict with subsite name.' );
+
+		// Reset the page mapping.
+		bp_update_option( 'bp-pages', $reset_option );
+		wp_delete_post( $bp_pages['newcomponent'], true );
+		$bp->pages = $reset_bp_pages;
+		$bp->active_components = $reset_bp_active_components;
+	}
+
+	public function add_newcomponent_page_title( $page_default_titles = array() ) {
+		return array_merge( $page_default_titles, array( 'newcomponent' => 'NewComponent' ) );
+	}
 }
