@@ -1494,6 +1494,7 @@ public function createDirRecursive($dirName, $perms)
14941494// Is this a file instead of a directory?
14951495if (is_file ($ root . $ path ))
14961496{
1497+ $ this ->clearFileInOPCache ($ root . $ path );
14971498@unlink ($ root . $ path );
14981499$ ret = @mkdir ($ root . $ path );
14991500}
@@ -1523,6 +1524,8 @@ public function chmod($file, $perms)
15231524
15241525public function unlink ($ file )
15251526{
1527+ $ this ->clearFileInOPCache ($ file );
1528+
15261529return @unlink ($ file );
15271530}
15281531
@@ -1533,7 +1536,20 @@ public function rmdir($directory)
15331536
15341537public function rename ($ from , $ to )
15351538{
1536- return @rename ($ from , $ to );
1539+ $ this ->clearFileInOPCache ($ from );
1540+ $ ret = @rename ($ from , $ to );
1541+ $ this ->clearFileInOPCache ($ to );
1542+
1543+ return $ ret ;
1544+ }
1545+
1546+ public function clearFileInOPCache ($ file ){
1547+ if (ini_get ('opcache.enable ' )
1548+ && function_exists ('opcache_invalidate ' )
1549+ && (!ini_get ('opcache.restrict_api ' ) || stripos (realpath ($ _SERVER ['SCRIPT_FILENAME ' ]), ini_get ('opcache.restrict_api ' )) === 0 ))
1550+ {
1551+ \opcache_invalidate ($ file , true );
1552+ }
15371553}
15381554
15391555}
@@ -5105,10 +5121,13 @@ public function __toString()
51055121$ filename = dirname (__FILE__ ) . '/restore_finalisation.php ' ;
51065122if (file_exists ($ filename ))
51075123{
5108- // opcode cache busting before including the filename
5109- if (function_exists ('opcache_invalidate ' ))
5124+ // We cannot use the Filesystem API here.
5125+ if (ini_get ('opcache.enable ' )
5126+ && function_exists ('opcache_invalidate ' )
5127+ && (!ini_get ('opcache.restrict_api ' ) || stripos (realpath ($ _SERVER ['SCRIPT_FILENAME ' ]), ini_get ('opcache.restrict_api ' )) === 0 )
5128+ )
51105129{
5111- \opcache_invalidate ($ filename );
5130+ \opcache_invalidate ($ filename, true );
51125131}
51135132if (function_exists ('apc_compile_file ' ))
51145133{
0 commit comments