first commit

This commit is contained in:
2024-10-25 14:16:28 +02:00
commit 925276dbb2
33795 changed files with 4780077 additions and 0 deletions

View File

@@ -0,0 +1,77 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/
namespace PrestaShop\Module\AutoUpgrade\TaskRunner\Miscellaneous;
use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeFileNames;
use PrestaShop\Module\AutoUpgrade\TaskRunner\AbstractTask;
/**
* List the files modified in the current installation regards to the original version.
*/
class CheckFilesVersion extends AbstractTask
{
public function run()
{
// do nothing after this request (see javascript function doAjaxRequest )
$this->next = '';
$upgrader = $this->container->getUpgrader();
$changedFileList = $upgrader->getChangedFilesList();
if ($changedFileList === false) {
$this->nextParams['status'] = 'error';
$this->nextParams['msg'] = $this->translator->trans('Unable to check files for the installed version of PrestaShop.', array(), 'Modules.Autoupgrade.Admin');
return;
}
foreach (array('core', 'translation', 'mail') as $type) {
if (!isset($changedFileList[$type])) {
$changedFileList[$type] = array();
}
}
if ($upgrader->isAuthenticPrestashopVersion() === true) {
$this->nextParams['status'] = 'ok';
$this->nextParams['msg'] = $this->translator->trans('Core files are ok', array(), 'Modules.Autoupgrade.Admin');
} else {
$this->nextParams['status'] = 'warn';
$this->nextParams['msg'] = $this->translator->trans(
'%modificationscount% file modifications have been detected, including %coremodifications% from core and native modules:',
array(
'%modificationscount%' => count(array_merge($changedFileList['core'], $changedFileList['mail'], $changedFileList['translation'])),
'%coremodifications%' => count($changedFileList['core']),
),
'Modules.Autoupgrade.Admin'
);
}
$this->nextParams['result'] = $changedFileList;
$this->container->getFileConfigurationStorage()->save($changedFileList['translation'], UpgradeFileNames::TRANSLATION_FILES_CUSTOM_LIST);
$this->container->getFileConfigurationStorage()->save($changedFileList['mail'], UpgradeFileNames::MAILS_CUSTOM_LIST);
}
}

View File

@@ -0,0 +1,84 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/
namespace PrestaShop\Module\AutoUpgrade\TaskRunner\Miscellaneous;
use PrestaShop\Module\AutoUpgrade\TaskRunner\AbstractTask;
use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeFileNames;
/**
* get the list of all modified and deleted files between current version
* and target version (according to channel configuration).
*/
class CompareReleases extends AbstractTask
{
public function run()
{
// do nothing after this request (see javascript function doAjaxRequest )
$this->next = '';
$channel = $this->container->getUpgradeConfiguration()->get('channel');
$upgrader = $this->container->getUpgrader();
switch ($channel) {
case 'archive':
$version = $this->container->getUpgradeConfiguration()->get('archive.version_num');
break;
case 'directory':
$version = $this->container->getUpgradeConfiguration()->get('directory.version_num');
break;
default:
preg_match('#([0-9]+\.[0-9]+)(?:\.[0-9]+){1,2}#', _PS_VERSION_, $matches);
$upgrader->branch = $matches[1];
$upgrader->channel = $channel;
if ($this->container->getUpgradeConfiguration()->get('channel') == 'private' && !$this->container->getUpgradeConfiguration()->get('private_allow_major')) {
$upgrader->checkPSVersion(false, array('private', 'minor'));
} else {
$upgrader->checkPSVersion(false, array('minor'));
}
$version = $upgrader->version_num;
}
$diffFileList = $upgrader->getDiffFilesList(_PS_VERSION_, $version);
if (!is_array($diffFileList)) {
$this->nextParams['status'] = 'error';
$this->nextParams['msg'] = sprintf('Unable to generate diff file list between %1$s and %2$s.', _PS_VERSION_, $version);
} else {
$this->container->getFileConfigurationStorage()->save($diffFileList, UpgradeFileNames::FILES_DIFF_LIST);
if (count($diffFileList) > 0) {
$this->nextParams['msg'] = $this->translator->trans(
'%modifiedfiles% files will be modified, %deletedfiles% files will be deleted (if they are found).',
array(
'%modifiedfiles%' => count($diffFileList['modified']),
'%deletedfiles%' => count($diffFileList['deleted']),
),
'Modules.Autoupgrade.Admin');
} else {
$this->nextParams['msg'] = $this->translator->trans('No diff files found.', array(), 'Modules.Autoupgrade.Admin');
}
$this->nextParams['result'] = $diffFileList;
}
}
}

View File

@@ -0,0 +1,56 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/
namespace PrestaShop\Module\AutoUpgrade\TaskRunner\Miscellaneous;
use PrestaShop\Module\AutoUpgrade\ChannelInfo;
use PrestaShop\Module\AutoUpgrade\TaskRunner\AbstractTask;
use PrestaShop\Module\AutoUpgrade\Twig\Block\ChannelInfoBlock;
/**
* display informations related to the selected channel : link/changelog for remote channel,
* or configuration values for special channels.
*/
class GetChannelInfo extends AbstractTask
{
public function run()
{
// do nothing after this request (see javascript function doAjaxRequest )
$this->next = '';
$channel = $this->container->getUpgradeConfiguration()->getChannel();
$channelInfo = (new ChannelInfo($this->container->getUpgrader(), $this->container->getUpgradeConfiguration(), $channel));
$channelInfoArray = $channelInfo->getInfo();
$this->nextParams['result']['available'] = $channelInfoArray['available'];
$this->nextParams['result']['div'] = (new ChannelInfoBlock(
$this->container->getUpgradeConfiguration(),
$channelInfo,
$this->container->getTwig())
)->render();
}
}

View File

@@ -0,0 +1,163 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/
namespace PrestaShop\Module\AutoUpgrade\TaskRunner\Miscellaneous;
use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeFileNames;
use PrestaShop\Module\AutoUpgrade\UpgradeContainer;
use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeConfigurationStorage;
use PrestaShop\Module\AutoUpgrade\TaskRunner\AbstractTask;
use PrestaShop\Module\AutoUpgrade\Upgrader;
/**
* update configuration after validating the new values.
*/
class UpdateConfig extends AbstractTask
{
/**
* Data being passed by CLI entry point
*
* @var array
*/
protected $cliParameters;
public function run()
{
// nothing next
$this->next = '';
// Was coming from AdminSelfUpgrade::currentParams before
$configurationData = $this->getConfigurationData();
$config = array();
// update channel
if (isset($configurationData['channel'])) {
$config['channel'] = $configurationData['channel'];
$config['archive.filename'] = Upgrader::DEFAULT_FILENAME;
// Switch on default theme if major upgrade (i.e: 1.6 -> 1.7)
$config['PS_AUTOUP_CHANGE_DEFAULT_THEME'] = ($configurationData['channel'] === 'major');
}
if (isset($configurationData['private_release_link'], $configurationData['private_release_md5'])) {
$config['channel'] = 'private';
$config['private_release_link'] = $configurationData['private_release_link'];
$config['private_release_md5'] = $configurationData['private_release_md5'];
$config['private_allow_major'] = $configurationData['private_allow_major'];
}
// if (!empty($request['archive_name']) && !empty($request['archive_num']))
if (!empty($configurationData['archive_prestashop'])) {
$file = $configurationData['archive_prestashop'];
if (!file_exists($this->container->getProperty(UpgradeContainer::DOWNLOAD_PATH) . DIRECTORY_SEPARATOR . $file)) {
$this->error = true;
$this->logger->info($this->translator->trans('File %s does not exist. Unable to select that channel.', array($file), 'Modules.Autoupgrade.Admin'));
return false;
}
if (empty($configurationData['archive_num'])) {
$this->error = true;
$this->logger->info($this->translator->trans('Version number is missing. Unable to select that channel.', array(), 'Modules.Autoupgrade.Admin'));
return false;
}
$config['channel'] = 'archive';
$config['archive.filename'] = $configurationData['archive_prestashop'];
$config['archive.version_num'] = $configurationData['archive_num'];
// $config['archive_name'] = $request['archive_name'];
$this->logger->info($this->translator->trans('Upgrade process will use archive.', array(), 'Modules.Autoupgrade.Admin'));
}
if (isset($configurationData['directory_num'])) {
$config['channel'] = 'directory';
if (empty($configurationData['directory_num']) || strpos($configurationData['directory_num'], '.') === false) {
$this->error = true;
$this->logger->info($this->translator->trans('Version number is missing. Unable to select that channel.', array(), 'Modules.Autoupgrade.Admin'));
return false;
}
$config['directory.version_num'] = $configurationData['directory_num'];
}
if (isset($configurationData['skip_backup'])) {
$config['skip_backup'] = $configurationData['skip_backup'];
}
if (isset($configurationData['PS_AUTOUP_CHANGE_DEFAULT_THEME'])) {
$config['PS_AUTOUP_CHANGE_DEFAULT_THEME'] = $configurationData['PS_AUTOUP_CHANGE_DEFAULT_THEME'];
}
if (!$this->writeConfig($config)) {
$this->error = true;
$this->logger->info($this->translator->trans('Error on saving configuration', array(), 'Modules.Autoupgrade.Admin'));
}
}
public function inputCliParameters($parameters)
{
$this->cliParameters = $parameters;
}
protected function getConfigurationData()
{
if (null !== $this->cliParameters) {
return $this->getCLIParams();
}
return $this->getRequestParams();
}
protected function getCLIParams()
{
if (empty($this->cliParameters)) {
throw new \RuntimeException('Empty CLI parameters - did CLI entry point failed to provide data?');
}
return $this->cliParameters;
}
protected function getRequestParams()
{
return empty($_REQUEST['params']) ? array() : $_REQUEST['params'];
}
/**
* update module configuration (saved in file UpgradeFiles::configFilename) with $new_config.
*
* @param array $config
*
* @return bool true if success
*/
private function writeConfig($config)
{
if (!$this->container->getFileConfigurationStorage()->exists(UpgradeFileNames::CONFIG_FILENAME) && !empty($config['channel'])) {
$this->container->getUpgrader()->channel = $config['channel'];
$this->container->getUpgrader()->checkPSVersion();
$this->container->getState()->setInstallVersion($this->container->getUpgrader()->version_num);
}
$this->container->getUpgradeConfiguration()->merge($config);
$this->logger->info($this->translator->trans('Configuration successfully updated.', array(), 'Modules.Autoupgrade.Admin') . ' <strong>' . $this->translator->trans('This page will now be reloaded and the module will check if a new version is available.', array(), 'Modules.Autoupgrade.Admin') . '</strong>');
return (new UpgradeConfigurationStorage($this->container->getProperty(UpgradeContainer::WORKSPACE_PATH) . DIRECTORY_SEPARATOR))->save($this->container->getUpgradeConfiguration(), UpgradeFileNames::CONFIG_FILENAME);
}
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;