diff --git src/wp-admin/includes/file.php src/wp-admin/includes/file.php
index f9f5be10cea..1c8123f62dd 100644
--- src/wp-admin/includes/file.php
+++ src/wp-admin/includes/file.php
@@ -2356,7 +2356,8 @@ function wp_opcache_invalidate( $filepath, $force = false ) {
 	}
 
 	// Verify that file to be invalidated has a PHP extension.
-	if ( ! preg_match( '/\.(?:php)$/i', $filepath ) ) {
+	if ( 4 <= strlen( $filepath )
+		&& 0 !== substr_compare( $filepath, '.php', -4, 4, true ) ) {
 		return false;
 	}
 
