/** * This function now replaces doUpgrade.php or upgrade.php * * @return void */ public function doUpgrade() { // Initialize // setting the memory limit to 128M only if current is lower $memory_limit = ini_get('memory_limit'); if (substr($memory_limit, -1) != 'G' && ((substr($memory_limit, -1) == 'M' and substr($memory_limit, 0, -1) < 128) || is_numeric($memory_limit) and intval($memory_limit) < 131072)) { @ini_set('memory_limit', '128M'); } /* Redefine REQUEST_URI if empty (on some webservers...) */ if (!isset($_SERVER['REQUEST_URI']) || empty($_SERVER['REQUEST_URI'])) { if (!isset($_SERVER['SCRIPT_NAME']) && isset($_SERVER['SCRIPT_FILENAME'])) { $_SERVER['SCRIPT_NAME'] = $_SERVER['SCRIPT_FILENAME']; } if (isset($_SERVER['SCRIPT_NAME'])) { if (basename($_SERVER['SCRIPT_NAME']) == 'index.php' && empty($_SERVER['QUERY_STRING'])) { $_SERVER['REQUEST_URI'] = dirname($_SERVER['SCRIPT_NAME']) . '/'; } else { $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) { $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; } } } } $_SERVER['REQUEST_URI'] = str_replace('//', '/', $_SERVER['REQUEST_URI']); define('INSTALL_VERSION', $this->install_version); // 1.4 define('INSTALL_PATH', realpath($this->latestRootDir . DIRECTORY_SEPARATOR . 'install')); // 1.5 ... define('_PS_INSTALL_PATH_', INSTALL_PATH . DIRECTORY_SEPARATOR); // 1.6 if (!defined('_PS_CORE_DIR_')) { define('_PS_CORE_DIR_', _PS_ROOT_DIR_); } define('PS_INSTALLATION_IN_PROGRESS', true); define('SETTINGS_FILE_PHP', $this->prodRootDir . '/app/config/parameters.php'); define('SETTINGS_FILE_YML', $this->prodRootDir . '/app/config/parameters.yml'); define('DEFINES_FILE', $this->prodRootDir . '/config/defines.inc.php'); define('INSTALLER__PS_BASE_URI', substr($_SERVER['REQUEST_URI'], 0, -1 * (strlen($_SERVER['REQUEST_URI']) - strrpos($_SERVER['REQUEST_URI'], '/')) - strlen(substr(dirname($_SERVER['REQUEST_URI']), strrpos(dirname($_SERVER['REQUEST_URI']), '/') + 1)))); // define('INSTALLER__PS_BASE_URI_ABSOLUTE', 'http://'.ToolsInstall::getHttpHost(false, true).INSTALLER__PS_BASE_URI); // XML Header // header('Content-Type: text/xml'); $filePrefix = 'PREFIX_'; $engineType = 'ENGINE_TYPE'; $mysqlEngine = defined('_MYSQL_ENGINE_') ? _MYSQL_ENGINE_ : 'MyISAM'; if (function_exists('date_default_timezone_set')) { date_default_timezone_set('Europe/Paris'); } // if _PS_ROOT_DIR_ is defined, use it instead of "guessing" the module dir. if (defined('_PS_ROOT_DIR_') and !defined('_PS_MODULE_DIR_')) { define('_PS_MODULE_DIR_', _PS_ROOT_DIR_ . '/modules/'); } elseif (!defined('_PS_MODULE_DIR_')) { define('_PS_MODULE_DIR_', INSTALL_PATH . '/../modules/'); } $upgrade_dir_php = 'upgrade/php'; if (!file_exists(INSTALL_PATH . DIRECTORY_SEPARATOR . $upgrade_dir_php)) { $upgrade_dir_php = 'php'; if (!file_exists(INSTALL_PATH . DIRECTORY_SEPARATOR . $upgrade_dir_php)) { $this->next = 'error'; $this->next_desc = $this->l('/install/upgrade/php directory is missing in archive or directory'); $this->nextQuickInfo[] = '/install/upgrade/php directory is missing in archive or directory'; $this->nextErrors[] = '/install/upgrade/php directory is missing in archive or directory.'; return false; } } define('_PS_INSTALLER_PHP_UPGRADE_DIR_', INSTALL_PATH . DIRECTORY_SEPARATOR . $upgrade_dir_php . DIRECTORY_SEPARATOR); //old version detection global $oldversion, $logger; $oldversion = false; if (!file_exists(SETTINGS_FILE_PHP)) { $this->next = 'error'; $this->nextQuickInfo[] = $this->l('The app/config/parameters.php file was not found.'); $this->nextErrors[] = $this->l('The app/config/parameters.php file was not found.'); return false; } if (!file_exists(SETTINGS_FILE_YML)) { $this->next = 'error'; $this->nextQuickInfo[] = $this->l('The app/config/parameters.yml file was not found.'); $this->nextErrors[] = $this->l('The app/config/parameters.yml file was not found.'); return false; } $oldversion = Configuration::get('PS_VERSION_DB'); if (!defined('__PS_BASE_URI__')) { define('__PS_BASE_URI__', realpath(dirname($_SERVER['SCRIPT_NAME'])) . '/../../'); } if (!defined('_THEMES_DIR_')) { define('_THEMES_DIR_', __PS_BASE_URI__ . 'themes/'); } $versionCompare = version_compare(INSTALL_VERSION, $oldversion); if ($versionCompare == '-1') { $this->next = 'error'; $this->nextQuickInfo[] = sprintf($this->l('Current version: %1$s. Version to install: %2$s.'), $oldversion, INSTALL_VERSION); $this->nextErrors[] = sprintf($this->l('Current version: %1$s. Version to install: %2$s'), $oldversion, INSTALL_VERSION); $this->nextQuickInfo[] = $this->l('[ERROR] Version to install is too old.'); $this->nextErrors[] = $this->l('[ERROR] Version to install is too old.'); return false; } elseif ($versionCompare == 0) { $this->next = 'error'; $this->nextQuickInfo[] = $this->l(sprintf('You already have the %s version.', INSTALL_VERSION)); $this->nextErrors[] = $this->l(sprintf('You already have the %s version.', INSTALL_VERSION)); return false; } elseif ($versionCompare === false) { $this->next = 'error'; $this->nextQuickInfo[] = $this->l('There is no older version. Did you delete or rename the app/config/parameters.php file?'); $this->nextErrors[] = $this->l('There is no older version. Did you delete or rename the app/config/parameters.php file?'); return false; } //check DB access $this->db; error_reporting(E_ALL); $resultDB = Db::checkConnection(_DB_SERVER_, _DB_USER_, _DB_PASSWD_, _DB_NAME_); if ($resultDB !== 0) { // $logger->logError('Invalid database configuration.'); $this->next = 'error'; $this->nextQuickInfo[] = $this->l('Invalid database configuration'); $this->nextErrors[] = $this->l('Invalid database configuration'); return false; } //custom sql file creation $upgradeFiles = array(); $upgrade_dir_sql = INSTALL_PATH . '/upgrade/sql'; // if 1.4; if (!file_exists($upgrade_dir_sql)) { $upgrade_dir_sql = INSTALL_PATH . '/sql/upgrade'; } if (!file_exists($upgrade_dir_sql)) { $this->next = 'error'; $this->next_desc = $this->l('Unable to find upgrade directory in the installation path.'); return false; } if ($handle = opendir($upgrade_dir_sql)) { while (false !== ($file = readdir($handle))) { if ($file != '.' and $file != '..') { $upgradeFiles[] = str_replace(".sql", "", $file); } } closedir($handle); } if (empty($upgradeFiles)) { $this->next = 'error'; $this->nextQuickInfo[] = sprintf($this->l('Cannot find the SQL upgrade files. Please check that the %s folder is not empty.'), $upgrade_dir_sql); $this->nextErrors[] = sprintf($this->l('Cannot find the SQL upgrade files. Please check that the %s folder is not empty.'), $upgrade_dir_sql); // fail 31 return false; } natcasesort($upgradeFiles); $neededUpgradeFiles = array(); $arrayVersion = explode('.', $oldversion); $versionNumbers = count($arrayVersion); if ($versionNumbers != 4) { $arrayVersion = array_pad($arrayVersion, 4, '0'); } $oldversion = implode('.', $arrayVersion); foreach ($upgradeFiles as $version) { if (version_compare($version, $oldversion) == 1 && version_compare(INSTALL_VERSION, $version) != -1) { $neededUpgradeFiles[] = $version; } } if (strpos(INSTALL_VERSION, '.') === false) { $this->nextQuickInfo[] = sprintf($this->l('%s is not a valid version number.'), INSTALL_VERSION); $this->nextErrors[] = sprintf($this->l('%s is not a valid version number.'), INSTALL_VERSION); return false; } $sqlContentVersion = array(); if ($this->deactivateCustomModule) { $this->disableNonNativeModules(); } foreach ($neededUpgradeFiles as $version) { $file = $upgrade_dir_sql . DIRECTORY_SEPARATOR . $version . '.sql'; if (!file_exists($file)) { $this->next = 'error'; $this->nextQuickInfo[] = sprintf($this->l('Error while loading SQL upgrade file "%s.sql".'), $version); $this->nextErrors[] = sprintf($this->l('Error while loading SQL upgrade file "%s.sql".'), $version); return false; $logger->logError('Error while loading SQL upgrade file.'); } if (!($sqlContent = file_get_contents($file) . "\n")) { $this->next = 'error'; $this->nextQuickInfo[] = $this->l(sprintf('Error while loading SQL upgrade file %s.', $version)); $this->nextErrors[] = $this->l(sprintf('Error while loading sql SQL file %s.', $version)); return false; $logger->logError(sprintf('Error while loading sql upgrade file %s.', $version)); } $sqlContent = str_replace(array($filePrefix, $engineType), array(_DB_PREFIX_, $mysqlEngine), $sqlContent); $sqlContent = preg_split("/;\\s*[\r\n]+/", $sqlContent); $sqlContentVersion[$version] = $sqlContent; } //sql file execution global $requests, $warningExist; $requests = ''; $warningExist = false; $request = ''; foreach ($sqlContentVersion as $upgrade_file => $sqlContent) { foreach ($sqlContent as $query) { $query = trim($query); if (!empty($query)) { /* If php code have to be executed */ if (strpos($query, '/* PHP:') !== false) { /* Parsing php code */ $pos = strpos($query, '/* PHP:') + strlen('/* PHP:'); $phpString = substr($query, $pos, strlen($query) - $pos - strlen(' */;')); $php = explode('::', $phpString); preg_match('/\\((.*)\\)/', $phpString, $pattern); $paramsString = trim($pattern[0], '()'); preg_match_all('/([^,]+),? ?/', $paramsString, $parameters); if (isset($parameters[1])) { $parameters = $parameters[1]; } else { $parameters = array(); } if (is_array($parameters)) { foreach ($parameters as &$parameter) { $parameter = str_replace('\'', '', $parameter); } } // reset phpRes to a null value $phpRes = null; /* Call a simple function */ if (strpos($phpString, '::') === false) { $func_name = str_replace($pattern[0], '', $php[0]); if (version_compare(INSTALL_VERSION, '1.5.5.0', '=') && $func_name == 'fix_download_product_feature_active') { continue; } if (!file_exists(_PS_INSTALLER_PHP_UPGRADE_DIR_ . strtolower($func_name) . '.php')) { $this->nextQuickInfo[] = '<div class="upgradeDbError">[ERROR] ' . $upgrade_file . ' PHP - missing file ' . $query . '</div>'; $this->nextErrors[] = '[ERROR] ' . $upgrade_file . ' PHP - missing file ' . $query; $warningExist = true; } else { require_once _PS_INSTALLER_PHP_UPGRADE_DIR_ . strtolower($func_name) . '.php'; $phpRes = call_user_func_array($func_name, $parameters); } } else { $func_name = array($php[0], str_replace($pattern[0], '', $php[1])); $this->nextQuickInfo[] = '<div class="upgradeDbError">[ERROR] ' . $upgrade_file . ' PHP - Object Method call is forbidden ( ' . $php[0] . '::' . str_replace($pattern[0], '', $php[1]) . ')</div>'; $this->nextErrors[] = '[ERROR] ' . $upgrade_file . ' PHP - Object Method call is forbidden (' . $php[0] . '::' . str_replace($pattern[0], '', $php[1]) . ')'; $warningExist = true; } if (isset($phpRes) && (is_array($phpRes) && !empty($phpRes['error'])) || $phpRes === false) { // $this->next = 'error'; $this->nextQuickInfo[] = ' <div class="upgradeDbError"> [ERROR] PHP ' . $upgrade_file . ' ' . $query . "\n" . ' ' . (empty($phpRes['error']) ? '' : $phpRes['error'] . "\n") . ' ' . (empty($phpRes['msg']) ? '' : ' - ' . $phpRes['msg'] . "\n") . ' </div>'; $this->nextErrors[] = ' [ERROR] PHP ' . $upgrade_file . ' ' . $query . "\n" . ' ' . (empty($phpRes['error']) ? '' : $phpRes['error'] . "\n") . ' ' . (empty($phpRes['msg']) ? '' : ' - ' . $phpRes['msg'] . "\n"); $warningExist = true; } else { $this->nextQuickInfo[] = '<div class="upgradeDbOk">[OK] PHP ' . $upgrade_file . ' : ' . $query . '</div>'; } if (isset($phpRes)) { unset($phpRes); } } else { if (strstr($query, 'CREATE TABLE') !== false) { $pattern = '/CREATE TABLE.*[`]*' . _DB_PREFIX_ . '([^`]*)[`]*\\s\\(/'; preg_match($pattern, $query, $matches); if (isset($matches[1]) && $matches[1]) { $drop = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . $matches[1] . '`;'; $result = $this->db->execute($drop, false); if ($result) { $this->nextQuickInfo[] = '<div class="upgradeDbOk">' . sprintf($this->l('[DROP] SQL %s table has been dropped.'), '`' . _DB_PREFIX_ . $matches[1] . '`') . '</div>'; } } } $result = $this->db->execute($query, false); if (!$result) { $error = $this->db->getMsgError(); $error_number = $this->db->getNumberError(); $this->nextQuickInfo[] = ' <div class="upgradeDbError"> [WARNING] SQL ' . $upgrade_file . ' ' . $error_number . ' in ' . $query . ': ' . $error . '</div>'; $duplicates = array('1050', '1054', '1060', '1061', '1062', '1091'); if (!in_array($error_number, $duplicates)) { $this->nextErrors[] = 'SQL ' . $upgrade_file . ' ' . $error_number . ' in ' . $query . ': ' . $error; $warningExist = true; } } else { $this->nextQuickInfo[] = '<div class="upgradeDbOk">[OK] SQL ' . $upgrade_file . ' ' . $query . '</div>'; } } if (isset($query)) { unset($query); } } } } if ($this->next == 'error') { $this->next_desc = $this->l('An error happened during the database upgrade.'); return false; } $sf2Refresh = new \PrestaShopBundle\Service\Cache\Refresh(); $sf2Refresh->addDoctrineSchemaUpdate(); $output = $sf2Refresh->execute(); if (0 !== $output['doctrine:schema:update']['exitCode']) { $msgErrors = explode("\n", $output['doctrine:schema:update']['output']); $this->nextErrors[] = $this->l('Error upgrading doctrine schema'); $this->nextQuickInfo[] = $msgErrors; $this->next_desc = $msgErrors; return false; } $this->nextQuickInfo[] = $this->l('Database upgrade OK'); // no error ! // Settings updated, compile and cache directories must be emptied $arrayToClean[] = $this->prodRootDir . '/app/cache/'; $arrayToClean[] = $this->prodRootDir . '/cache/smarty/cache/'; $arrayToClean[] = $this->prodRootDir . '/cache/smarty/compile/'; foreach ($arrayToClean as $dir) { if (!file_exists($dir)) { $this->nextQuickInfo[] = sprintf($this->l('[SKIP] directory "%s" does not exist and cannot be emptied.'), str_replace($this->prodRootDir, '', $dir)); continue; } else { foreach (scandir($dir) as $file) { if ($file[0] != '.' && $file != 'index.php' && $file != '.htaccess') { if (is_file($dir . $file)) { unlink($dir . $file); } elseif (is_dir($dir . $file . DIRECTORY_SEPARATOR)) { self::deleteDirectory($dir . $file . DIRECTORY_SEPARATOR); } $this->nextQuickInfo[] = sprintf($this->l('[CLEANING CACHE] File %s removed'), $file); } } } } $this->db->execute('UPDATE `' . _DB_PREFIX_ . 'configuration` SET `name` = \'PS_LEGACY_IMAGES\' WHERE name LIKE \'0\' AND `value` = 1'); $this->db->execute('UPDATE `' . _DB_PREFIX_ . 'configuration` SET `value` = 0 WHERE `name` LIKE \'PS_LEGACY_IMAGES\''); if ($this->db->getValue('SELECT COUNT(id_product_download) FROM `' . _DB_PREFIX_ . 'product_download` WHERE `active` = 1') > 0) { $this->db->execute('UPDATE `' . _DB_PREFIX_ . 'configuration` SET `value` = 1 WHERE `name` LIKE \'PS_VIRTUAL_PROD_FEATURE_ACTIVE\''); } if (defined('_THEME_NAME_') && $this->updateDefaultTheme && 'classic' === _THEME_NAME_) { $separator = addslashes(DIRECTORY_SEPARATOR); $file = _PS_ROOT_DIR_ . $separator . 'themes' . $separator . _THEME_NAME_ . $separator . 'cache' . $separator; if (file_exists($file)) { foreach (scandir($file) as $cache) { if ($cache[0] != '.' && $cache != 'index.php' && $cache != '.htaccess' && file_exists($file . $cache) && !is_dir($file . $cache)) { if (file_exists($dir . $cache)) { unlink($file . $cache); } } } } } // Upgrade languages if (!defined('_PS_TOOL_DIR_')) { define('_PS_TOOL_DIR_', _PS_ROOT_DIR_ . '/tools/'); } if (!defined('_PS_TRANSLATIONS_DIR_')) { define('_PS_TRANSLATIONS_DIR_', _PS_ROOT_DIR_ . '/translations/'); } if (!defined('_PS_MODULES_DIR_')) { define('_PS_MODULES_DIR_', _PS_ROOT_DIR_ . '/modules/'); } if (!defined('_PS_MAILS_DIR_')) { define('_PS_MAILS_DIR_', _PS_ROOT_DIR_ . '/mails/'); } $langs = $this->db->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'lang` WHERE `active` = 1'); if (is_array($langs)) { foreach ($langs as $lang) { $isoCode = $lang['iso_code']; if (Validate::isLangIsoCode($isoCode)) { $errorsLanguage = array(); Language::downloadLanguagePack($isoCode, _PS_VERSION_, $errorsLanguage); $lang_pack = Language::getLangDetails($isoCode); Language::installSfLanguagePack($lang_pack['locale'], $errorsLanguage); if (!$this->keepMails) { Language::installEmailsLanguagePack($lang_pack, $errorsLanguage); } if (empty($errorsLanguage)) { Language::loadLanguages(); // TODO: Update AdminTranslationsController::addNewTabs to install tabs translated $cldrUpdate = new \PrestaShop\PrestaShop\Core\Cldr\Update(_PS_TRANSLATIONS_DIR_); $cldrUpdate->fetchLocale(Language::getLocaleByIso($isoCode)); } else { $this->nextErrors[] = $this->l('Error updating translations'); $this->nextQuickInfo[] = $this->l('Error updating translations'); $this->next_desc = $this->l('Error updating translations'); return false; } } } } require_once _PS_ROOT_DIR_ . '/src/Core/Foundation/Database/EntityInterface.php'; if (file_exists(_PS_ROOT_DIR_ . '/classes/Tools.php')) { require_once _PS_ROOT_DIR_ . '/classes/Tools.php'; } if (!class_exists('Tools2', false) and class_exists('ToolsCore')) { eval('class Tools2 extends ToolsCore{}'); } if (class_exists('Tools2') && method_exists('Tools2', 'generateHtaccess')) { $url_rewrite = (bool) $this->db->getvalue('SELECT `value` FROM `' . _DB_PREFIX_ . 'configuration` WHERE name=\'PS_REWRITING_SETTINGS\''); if (!defined('_MEDIA_SERVER_1_')) { define('_MEDIA_SERVER_1_', ''); } if (!defined('_PS_USE_SQL_SLAVE_')) { define('_PS_USE_SQL_SLAVE_', false); } if (file_exists(_PS_ROOT_DIR_ . '/classes/ObjectModel.php')) { require_once _PS_ROOT_DIR_ . '/classes/ObjectModel.php'; } if (!class_exists('ObjectModel', false) and class_exists('ObjectModelCore')) { eval('abstract class ObjectModel extends ObjectModelCore{}'); } if (file_exists(_PS_ROOT_DIR_ . '/classes/Configuration.php')) { require_once _PS_ROOT_DIR_ . '/classes/Configuration.php'; } if (!class_exists('Configuration', false) and class_exists('ConfigurationCore')) { eval('class Configuration extends ConfigurationCore{}'); } if (file_exists(_PS_ROOT_DIR_ . '/classes/cache/Cache.php')) { require_once _PS_ROOT_DIR_ . '/classes/cache/Cache.php'; } if (!class_exists('Cache', false) and class_exists('CacheCore')) { eval('abstract class Cache extends CacheCore{}'); } if (file_exists(_PS_ROOT_DIR_ . '/classes/PrestaShopCollection.php')) { require_once _PS_ROOT_DIR_ . '/classes/PrestaShopCollection.php'; } if (!class_exists('PrestaShopCollection', false) and class_exists('PrestaShopCollectionCore')) { eval('class PrestaShopCollection extends PrestaShopCollectionCore{}'); } if (file_exists(_PS_ROOT_DIR_ . '/classes/shop/ShopUrl.php')) { require_once _PS_ROOT_DIR_ . '/classes/shop/ShopUrl.php'; } if (!class_exists('ShopUrl', false) and class_exists('ShopUrlCore')) { eval('class ShopUrl extends ShopUrlCore{}'); } if (file_exists(_PS_ROOT_DIR_ . '/classes/shop/Shop.php')) { require_once _PS_ROOT_DIR_ . '/classes/shop/Shop.php'; } if (!class_exists('Shop', false) and class_exists('ShopCore')) { eval('class Shop extends ShopCore{}'); } if (file_exists(_PS_ROOT_DIR_ . '/classes/Translate.php')) { require_once _PS_ROOT_DIR_ . '/classes/Translate.php'; } if (!class_exists('Translate', false) and class_exists('TranslateCore')) { eval('class Translate extends TranslateCore{}'); } if (file_exists(_PS_ROOT_DIR_ . '/classes/module/Module.php')) { require_once _PS_ROOT_DIR_ . '/classes/module/Module.php'; } if (!class_exists('Module', false) and class_exists('ModuleCore')) { eval('class Module extends ModuleCore{}'); } if (file_exists(_PS_ROOT_DIR_ . '/classes/Validate.php')) { require_once _PS_ROOT_DIR_ . '/classes/Validate.php'; } if (!class_exists('Validate', false) and class_exists('ValidateCore')) { eval('class Validate extends ValidateCore{}'); } if (file_exists(_PS_ROOT_DIR_ . '/classes/Language.php')) { require_once _PS_ROOT_DIR_ . '/classes/Language.php'; } if (!class_exists('Language', false) and class_exists('LanguageCore')) { eval('class Language extends LanguageCore{}'); } if (file_exists(_PS_ROOT_DIR_ . '/classes/Tab.php')) { require_once _PS_ROOT_DIR_ . '/classes/Tab.php'; } if (!class_exists('Tab', false) and class_exists('TabCore')) { eval('class Tab extends TabCore{}'); } if (file_exists(_PS_ROOT_DIR_ . '/classes/Dispatcher.php')) { require_once _PS_ROOT_DIR_ . '/classes/Dispatcher.php'; } if (!class_exists('Dispatcher', false) and class_exists('DispatcherCore')) { eval('class Dispatcher extends DispatcherCore{}'); } if (file_exists(_PS_ROOT_DIR_ . '/classes/Hook.php')) { require_once _PS_ROOT_DIR_ . '/classes/Hook.php'; } if (!class_exists('Hook', false) and class_exists('HookCore')) { eval('class Hook extends HookCore{}'); } if (file_exists(_PS_ROOT_DIR_ . '/classes/Context.php')) { require_once _PS_ROOT_DIR_ . '/classes/Context.php'; } if (!class_exists('Context', false) and class_exists('ContextCore')) { eval('class Context extends ContextCore{}'); } if (file_exists(_PS_ROOT_DIR_ . '/classes/Group.php')) { require_once _PS_ROOT_DIR_ . '/classes/Group.php'; } if (!class_exists('Group', false) and class_exists('GroupCore')) { eval('class Group extends GroupCore{}'); } Tools2::generateHtaccess(null, $url_rewrite); } $path = $this->adminDir . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . 'default' . DIRECTORY_SEPARATOR . 'template' . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'header.tpl'; if (file_exists($path)) { unlink($path); } if (file_exists(_PS_ROOT_DIR_ . '/app/cache/dev/class_index.php')) { unlink(_PS_ROOT_DIR_ . '/app/cache/dev/class_index.php'); } if (file_exists(_PS_ROOT_DIR_ . '/app/cache/prod/class_index.php')) { unlink(_PS_ROOT_DIR_ . '/app/cache/prod/class_index.php'); } // Clear XML files if (file_exists(_PS_ROOT_DIR_ . '/config/xml/blog-fr.xml')) { unlink(_PS_ROOT_DIR_ . '/config/xml/blog-fr.xml'); } if (file_exists(_PS_ROOT_DIR_ . '/config/xml/default_country_modules_list.xml')) { unlink(_PS_ROOT_DIR_ . '/config/xml/default_country_modules_list.xml'); } if (file_exists(_PS_ROOT_DIR_ . '/config/xml/modules_list.xml')) { unlink(_PS_ROOT_DIR_ . '/config/xml/modules_list.xml'); } if (file_exists(_PS_ROOT_DIR_ . '/config/xml/modules_native_addons.xml')) { unlink(_PS_ROOT_DIR_ . '/config/xml/modules_native_addons.xml'); } if (file_exists(_PS_ROOT_DIR_ . '/config/xml/must_have_modules_list.xml')) { unlink(_PS_ROOT_DIR_ . '/config/xml/must_have_modules_list.xml'); } if (file_exists(_PS_ROOT_DIR_ . '/config/xml/tab_modules_list.xml')) { unlink(_PS_ROOT_DIR_ . '/config/xml/tab_modules_list.xml'); } if (file_exists(_PS_ROOT_DIR_ . '/config/xml/trusted_modules_list.xml')) { unlink(_PS_ROOT_DIR_ . '/config/xml/trusted_modules_list.xml'); } if (file_exists(_PS_ROOT_DIR_ . '/config/xml/untrusted_modules_list.xml')) { unlink(_PS_ROOT_DIR_ . '/config/xml/untrusted_modules_list.xml'); } if ($this->deactivateCustomModule) { $exist = $this->db->getValue('SELECT `id_configuration` FROM `' . _DB_PREFIX_ . 'configuration` WHERE `name` LIKE \'PS_DISABLE_OVERRIDES\''); if ($exist) { $this->db->execute('UPDATE `' . _DB_PREFIX_ . 'configuration` SET value = 1 WHERE `name` LIKE \'PS_DISABLE_OVERRIDES\''); } else { $this->db->execute('INSERT INTO `' . _DB_PREFIX_ . 'configuration` (name, value, date_add, date_upd) VALUES ("PS_DISABLE_OVERRIDES", 1, NOW(), NOW())'); } if (file_exists(_PS_ROOT_DIR_ . '/classes/PrestaShopAutoload.php')) { require_once _PS_ROOT_DIR_ . '/classes/PrestaShopAutoload.php'; } if (class_exists('PrestaShopAutoload') && method_exists('PrestaShopAutoload', 'generateIndex')) { PrestaShopAutoload::getInstance()->_include_override_path = false; PrestaShopAutoload::getInstance()->generateIndex(); } } $themeManager = $this->getThemeManager(); $themeName = $this->changeToDefaultTheme ? 'classic' : _THEME_NAME_; $isThemeEnabled = $themeManager->enable($themeName); if (!$isThemeEnabled) { $themeErrors = $themeManager->getErrors($themeName); $this->nextQuickInfo[] = $themeErrors; $this->nextErrors[] = $themeErrors; $this->next_desc = $themeErrors; return false; } else { Tools::clearCache(); } // delete cache filesystem if activated if (defined('_PS_CACHE_ENABLED_') && _PS_CACHE_ENABLED_) { $depth = (int) $this->db->getValue('SELECT value FROM ' . _DB_PREFIX_ . 'configuration WHERE name = "PS_CACHEFS_DIRECTORY_DEPTH"'); if ($depth) { if (!defined('_PS_CACHEFS_DIRECTORY_')) { define('_PS_CACHEFS_DIRECTORY_', $this->prodRootDir . '/cache/cachefs/'); } self::deleteDirectory(_PS_CACHEFS_DIRECTORY_, false); if (class_exists('CacheFs', false)) { self::createCacheFsDirectories((int) $depth); } } } $this->db->execute('UPDATE `' . _DB_PREFIX_ . 'configuration` SET value="0" WHERE name = "PS_HIDE_OPTIMIZATION_TIS"', false); $this->db->execute('UPDATE `' . _DB_PREFIX_ . 'configuration` SET value="1" WHERE name = "PS_NEED_REBUILD_INDEX"', false); $this->db->execute('UPDATE `' . _DB_PREFIX_ . 'configuration` SET value="' . INSTALL_VERSION . '" WHERE name = "PS_VERSION_DB"', false); if ($warningExist) { $this->warning_exists = true; $this->nextQuickInfo[] = $this->l('Warning detected during upgrade.'); $this->nextErrors[] = $this->l('Warning detected during upgrade.'); $this->next_desc = $this->l('Warning detected during upgrade.'); } else { $this->next_desc = $this->l('Database upgrade completed'); } return true; }
/** * Pass SF2 to production * cache:clear * assetic:dump * doctrine:schema:update * * @return bool */ private function generateSf2ProductionEnv() { $sf2Refresh = new \PrestaShopBundle\Service\Cache\Refresh(); $sf2Refresh->addDoctrineSchemaUpdate(); $output = $sf2Refresh->execute(); if (0 !== $output['doctrine:schema:update']['exitCode']) { $this->setError(explode("\n", $output['doctrine:schema:update']['output'])); return false; } return true; }