diff --git src/wp-includes/plugin.php src/wp-includes/plugin.php
index e445dd8ea5..4083b99695 100644
--- src/wp-includes/plugin.php
+++ src/wp-includes/plugin.php
@@ -772,6 +772,7 @@ function plugin_basename( $file ) {
 	foreach ( $wp_plugin_paths as $dir => $realdir ) {
 		if ( strpos( $file, $realdir ) === 0 ) {
 			$file = $dir . substr( $file, strlen( $realdir ) );
+			break;
 		}
 	}
 
diff --git tests/phpunit/tests/functions/pluginBasename.php tests/phpunit/tests/functions/pluginBasename.php
index d28cf914cf..50d0bf2238 100644
--- tests/phpunit/tests/functions/pluginBasename.php
+++ tests/phpunit/tests/functions/pluginBasename.php
@@ -62,4 +62,26 @@ class Tests_Functions_PluginBasename extends WP_UnitTestCase {
 		$basename = plugin_basename( '/Users/me/Dropbox/Development/Repositories/plugin/trunk/plugin.php' );
 		$this->assertSame( 'trunk/plugin.php', $basename );
 	}
+
+	/**
+	 * Mimic a parent project directory that contains a plugin and WordPress installation. E.g.
+	 *
+	 *   Project directory: ../Projects/plugin-root
+	 *   WordPress install: ../Projects/plugin-root/wordpress
+	 *
+	 * @ticket 42670
+	 */
+	public function test_should_return_correct_basename_for_plugin_when_wp_plugins_dir_is_subdir_of_symlinked_plugin() {
+		global $wp_plugin_paths;
+
+		$plugin_project_root_directory = dirname( $this->wp_plugin_path, 3 );
+
+		$wp_plugin_paths = array(
+			$this->wp_plugin_path . '/plugin-root' => $plugin_project_root_directory,
+			$this->wp_plugin_path . '/woocommerce' => $plugin_project_root_directory . '/wordpress/wp-content/plugins/woocommerce',
+		);
+
+		$actual = plugin_basename( $plugin_project_root_directory . '/wordpress/wp-content/plugins/woocommerce/woocommerce.php' );
+		$this->assertSame( 'woocommerce/woocommerce.php', $actual, 'The basename returned is incorrect.' );
+	}
 }
