Initial Commit

This commit is contained in:
2019-11-21 12:25:31 +01:00
commit f4aabcb9b1
13959 changed files with 787761 additions and 0 deletions

View File

View File

@@ -0,0 +1,7 @@
<?php
$secret = \Thelia\Tools\TokenProvider::generateToken();
$sql = "UPDATE `config` SET `value`=? WHERE `name`='form.secret'";
$database->execute($sql, [$secret]);

View File

@@ -0,0 +1,7 @@
<?php
$secret = \Thelia\Tools\TokenProvider::generateToken();
$sql = "UPDATE `config` SET `value`=? WHERE `name`='form.secret'";
$database->execute($sql, [$secret]);

View File

@@ -0,0 +1,42 @@
<?php
$pdo = $database->getConnection();
// Get locale
$locale = 'fr_FR';
$sqlGetLocale = "SELECT `locale` FROM `lang` WHERE `by_default` = :by_default";
$stmtGetLocale = $pdo->prepare($sqlGetLocale);
$stmtGetLocale->execute([':by_default' => 1]);
$resultLocales = $stmtGetLocale->fetchAll();
foreach ($resultLocales as $defaultLocale) {
$locale = $defaultLocale['locale'];
}
// Get id, feature_id and free_text_value from feature_product
$sqlGetFeatureProduct = "SELECT `id`, `feature_id`, `free_text_value` FROM `feature_product` WHERE `feature_av_id` IS NULL";
$stmtGetFeatureProduct = $pdo->prepare($sqlGetFeatureProduct);
$stmtGetFeatureProduct->execute([':feature_av_id' => NULL]);
while ($featureProduct = $stmtGetFeatureProduct->fetch(PDO::FETCH_ASSOC)) {
// Create new feature_av with the feature_id
$sqlCreateFeatureAv = "INSERT INTO `feature_av` (feature_id, `position`) VALUES (:feature_id, :feature_position)";
$stmtCreateFeatureAv = $pdo->prepare($sqlCreateFeatureAv);
$stmtCreateFeatureAv->execute([':feature_id' => $featureProduct['feature_id'], ':feature_position' => 1]);
// Get id from created feature_av
$createdFeatureAvId = $pdo->lastInsertId();
// Create new feature_av_i18n
$sqlCreateFeatureAvI18n = "INSERT INTO `feature_av_i18n` (id, locale, title) VALUES (:id, :locale, :title)";
$stmtCreateFeatureAvI18n = $pdo->prepare($sqlCreateFeatureAvI18n);
$stmtCreateFeatureAvI18n->execute([':id' => $createdFeatureAvId, ':locale' => $locale, ':title' => $featureProduct['free_text_value']]);
// Update old NULL feature_av_id and textual free_text_value values from feature_product
$sqlUpdateFeatureProduct = "UPDATE feature_product SET feature_av_id = :feature_av_id, free_text_value = :free_text_value WHERE id = :featureProductId";
$stmtUpdateFeatureProduct = $pdo->prepare($sqlUpdateFeatureProduct);
$stmtUpdateFeatureProduct->execute([':feature_av_id' => $createdFeatureAvId, ':free_text_value' => 1, ':featureProductId' => $featureProduct['id']]);
}

View File

@@ -0,0 +1,53 @@
<?php
$pdo = $database->getConnection();
// Test if price columns are in float
$sqlGetFloat = "SELECT COLUMN_NAME "
. "FROM INFORMATION_SCHEMA.COLUMNS "
. "WHERE TABLE_SCHEMA LIKE DATABASE() AND TABLE_NAME LIKE 'product_price' AND COLUMN_NAME LIKE 'price' AND COLUMN_TYPE LIKE 'float%'";
$stmtGetFloat = $pdo->query($sqlGetFloat);
// alter tables to convert float to decimal
if ($stmtGetFloat->rowCount() !== 0) {
$columns = [
['product_price', 'price'],
['product_price', 'promo_price'],
['order_product', 'price'],
['order', 'discount'],
['order', 'postage'],
['order', 'postage_tax'],
['order_version', 'discount'],
['order_version', 'postage'],
['order_version', 'postage_tax'],
['order_product_tax', 'amount'],
['order_product_tax', 'promo_amount'],
['cart', 'discount'],
['cart_item', 'price'],
['cart_item', 'promo_price'],
['order_coupon', 'amount']
];
$queries = [
"ALTER TABLE `:table:` ADD COLUMN `:column:_temp` DECIMAL( 16, 6 ) NOT NULL DEFAULT '0.00000000' AFTER `:column:`",
"UPDATE `:table:` SET `:column:_temp` = CAST(`:column:` as CHAR)",
"ALTER TABLE `:table:` DROP COLUMN `:column:`",
"ALTER TABLE `:table:` CHANGE COLUMN `:column:_temp` `:column:` DECIMAL( 16, 6 ) NOT NULL DEFAULT '0.00000000'",
];
foreach ($columns as $column) {
$args = [
':table:' => $column[0],
':column:' => $column[1]
];
foreach ($queries as $query) {
$stmtConvert = $pdo->prepare(strtr($query, $args));
$stmtConvert->execute();
}
}
$stmtConvert = $pdo->prepare("ALTER TABLE `order_product` CHANGE `promo_price` `promo_price` DECIMAL( 16, 6 ) NOT NULL DEFAULT '0.00000000'");
$stmtConvert->execute();
}

View File

@@ -0,0 +1,29 @@
<?php
$fs = new \Symfony\Component\Filesystem\Filesystem();
$modules = [
'Carousel',
'Cheque',
'Colissimo',
'HookAnalytics',
'HookSocial',
'Tinymce'
];
foreach ($modules as $moduleCode) {
$path = THELIA_MODULE_DIR . $moduleCode . DS . 'AdminIncludes';
if ($fs->exists($path)) {
try {
$fs->remove($path);
} catch (Exception $e) {
$message = sprintf(
$this->trans('The update cannot delete the folder : "%s". Please delete this folder manually.'),
$path
);
$this->log('warning', $message);
$this->setMessage($message, 'warning');
}
}
}