From 81c39e949f3aab427e83fe77cea15c907fb77e56 Mon Sep 17 00:00:00 2001 From: Mike Schroder Date: Tue, 28 Jul 2020 08:07:04 +0000 Subject: [PATCH] Upgrade/Install: Improve `wp_opcache_invalidate()` performance. Changes from using `preg_match()` based `.php` extension checking to using `substr()` in `wp_opcache_invalidate()`. Props jnylen0, aaroncampbell, SergeyBiryukov, desrosj, mikeschroder. Fixes #50784. git-svn-id: https://develop.svn.wordpress.org/trunk@48657 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/file.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/file.php b/src/wp-admin/includes/file.php index f9f5be10ce..7bb04f8fc3 100644 --- a/src/wp-admin/includes/file.php +++ b/src/wp-admin/includes/file.php @@ -2356,7 +2356,7 @@ function wp_opcache_invalidate( $filepath, $force = false ) { } // Verify that file to be invalidated has a PHP extension. - if ( ! preg_match( '/\.(?:php)$/i', $filepath ) ) { + if ( '.php' !== strtolower( substr( $filepath, -4 ) ) ) { return false; }