unlink($fileName); } } } // Fake the JFolder class, mapping it to Restore's post-processing class if (!class_exists('JFolder')) { /** * JFolder mock class proxing behaviour in the post-upgrade script to that of either native PHP or restore.php * * @since 3.5.1 */ abstract class JFolder { /** * Proxies checking a folder exists to the native php version * * @param string $folderName The path to the folder to be checked * * @return boolean * * @since 3.5.1 */ public static function exists($folderName) { return @is_dir($folderName); } /** * Proxies deleting a folder to the restore.php version * * @param string $folderName The path to the folder to be deleted * * @return void * * @since 3.5.1 */ public static function delete($folderName) { recursive_remove_directory($folderName); } } } // Fake the JText class - we aren't going to show errors to people anyhow if (!class_exists('JText')) { /** * JText mock class proxing behaviour in the post-upgrade script to that of either native PHP or restore.php * * @since 3.5.1 */ abstract class JText { /** * No need for translations in a non-interactive script, so always return an empty string here * * @param string $text A language constant * * @return string * * @since 3.5.1 */ public static function sprintf($text) { return ''; } } } if (!function_exists('finalizeRestore')) { /** * Run part of the Joomla! finalisation script, namely the part that cleans up unused files/folders * * @param string $siteRoot The root to the Joomla! site * @param string $restorePath The base path to restore.php * * @return void * * @since 3.5.1 */ function finalizeRestore($siteRoot, $restorePath) { if (!defined('JPATH_ROOT')) { define('JPATH_ROOT', $siteRoot); } $filePath = JPATH_ROOT . '/administrator/components/com_admin/script.php'; if (file_exists($filePath)) { require_once $filePath; } // Make sure Joomla!'s code can figure out which files exist and need be removed clearstatcache(); // Remove obsolete files - prevents errors occurring in some system plugins if (class_exists('JoomlaInstallerScript')) { $script = new JoomlaInstallerScript; $script->deleteUnexistingFiles(); } // Clear OPcache if (function_exists('opcache_reset')) { opcache_reset(); } elseif (function_exists('apc_clear_cache')) { @apc_clear_cache(); } } }