Skip to content

Commit

Permalink
Merge pull request #70 from kmtbase/feature_oxid_700
Browse files Browse the repository at this point in the history
  • Loading branch information
TumTum authored Nov 24, 2023
2 parents 8ec1c01 + 70af100 commit 102af40
Show file tree
Hide file tree
Showing 23 changed files with 87 additions and 281 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/oxrun.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ jobs:
strategy:
matrix:
oxid:
- metapackage: "7.0-rc"
- metapackage: "7.0"
php: "8.0"
- metapackage: "6.3"
php: "8.0"
- metapackage: "6.2"
php: "7.4"

runs-on: ubuntu-latest
container:
Expand All @@ -32,12 +28,13 @@ jobs:
DOCKER_DOCUMENT_ROOT: /var/www/oxid-esale
MYSQL_HOST: oxid_db
MYSQL_DATABASE: 'oxid'
MYSQL_PORT: '3306'
MYSQL_USER: "oxid"
MYSQL_PASSWORD: "oxid"
OXID_SHOP_URL: "http://localhost"
services:
oxid_db:
image: mysql:5.7
image: mysql:8.0
env:
MYSQL_DATABASE: oxid
MYSQL_USER: oxid
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [v5.1.2] 2022-03-01
- Bugfix: Error on rerunning composer install [Issue #62](https://github.com/OXIDprojects/oxrun/issues/62)

### Fixed
## [v5.1.1] 2021-10-12
### Fixed
- Bugfix: configs for theme are no longer stored in the oxid configurations yaml, too. (PR #61)

## [v5.1.0] 2021-09-07
### Changed
- `oxrun-light` is now officially documented.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"oe-console"
],
"require": {
"oxid-esales/oxideshop-ce": "^v6.5 || ^7.0",
"oxid-esales/oxideshop-ce": "^7.0",
"guzzlehttp/guzzle": "*",
"nelexa/zip": "*"
},
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ services:
DOCKER_DOCUMENT_ROOT: /var/www/oxid-esale
MYSQL_HOST: oxid_db
MYSQL_DATABASE: 'oxid'
MYSQL_PORT: '3306'
MYSQL_USER: "oxid"
MYSQL_PASSWORD: "oxid"
OXID_SHOP_URL: "http://oxid-esale.local:8082"
Expand Down
1 change: 1 addition & 0 deletions docker/bin/installOxid.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ if [ ! -f "${DOCKER_DOCUMENT_ROOT}/source/config.inc.php" ]; then
sed -i "s/<dbName>/${MYSQL_DATABASE}/" ${source_dir}/config.inc.php && \
sed -i "s/<dbUser>/${MYSQL_USER}/" ${source_dir}/config.inc.php && \
sed -i "s/<dbPwd>/${MYSQL_PASSWORD}/" ${source_dir}/config.inc.php && \
sed -i "s/<dbPort>/${MYSQL_PORT}/" ${source_dir}/config.inc.php && \
sed -i "s|<sShopURL>|${OXID_SHOP_URL}|" ${source_dir}/config.inc.php && \
sed -i "s/'<sShopDir>'/__DIR__ . '\/'/" ${source_dir}/config.inc.php && \
sed -i "s/'<sCompileDir>'/__DIR__ . '\/tmp'/" ${source_dir}/config.inc.php
Expand Down
22 changes: 9 additions & 13 deletions services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ services:
- { name: console.command, command: 'module:list' }
Oxrun\Command\Module\ReloadCommand:
tags:
- { name: console.command }
- { name: console.command, command: 'module:reload' }
autowire: true
Oxrun\Command\Oxid\ShopListCommand:
tags:
Expand All @@ -75,37 +75,33 @@ services:
- { name: console.command, command: 'views:update' }
Oxrun\Command\Deploy\UpdateModuleConfigCommand:
tags:
- { name: console.command }
autowire: true
Oxrun\Command\Deploy\ModuleApplyConfigurationLightCommand:
tags:
- { name: console.command }
- { name: console.command, command: 'deploy:update-module-config' }
autowire: true
Oxrun\Command\Deploy\ModuleActivatorCommand:
tags:
- { name: console.command }
- { name: console.command, command: 'deploy:module-activator' }
autowire: true
Oxrun\Command\Config\GetCommand:
tags:
- { name: console.command }
- { name: console.command, command: 'config:get' }
autowire: true
Oxrun\Command\Deploy\GenerateModuleActivatorCommand:
tags:
- { name: console.command }
- { name: console.command, command: 'deploy:generate:module-activator' }
autowire: true
Oxrun\Command\Deploy\GenerateConfigurationCommand:
tags:
- { name: console.command }
- { name: console.command, command: 'deploy:generate:configuration' }
autowire: true
Oxrun\Command\Deploy\ConfigCommand:
tags:
- { name: console.command }
- { name: console.command, command: 'deploy:config' }
autowire: true
Oxrun\Command\Config\SetCommand:
tags:
- { name: console.command }
- { name: console.command, command: 'config:set' }
autowire: true
Oxrun\Command\Deploy\LinkEnvironmentCommand:
tags:
- { name: console.command }
- { name: console.command, command: 'deploy:link:environment' }
autowire: true
2 changes: 1 addition & 1 deletion src/Oxrun/Application/oxrun-light.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class OxrunLight extends \Symfony\Component\Console\Application
/**
* @inheritDoc
*/
public function getHelp()
public function getHelp(): string
{
$version = parent::getHelp();
return <<<TAG
Expand Down
2 changes: 1 addition & 1 deletion src/Oxrun/Command/Cache/ClearCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Exception\FileNotFoundException;
use Webmozart\PathUtil\Path;
use Symfony\Component\Filesystem\Path;

/**
* Class ClearCommand
Expand Down
25 changes: 13 additions & 12 deletions src/Oxrun/Command/Database/DumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$dbName = Registry::getConfig()->getConfigParam('dbName');

if($input->getOption('ignoreViews')) {
$viewsResultArray = \oxDb::getDb()->getAll("SHOW FULL TABLES IN {$dbName} WHERE TABLE_TYPE LIKE 'VIEW'");
$viewsResultArray = \oxDb::getDb()->getAll("SHOW FULL TABLES IN `{$dbName}` WHERE TABLE_TYPE LIKE 'VIEW'");
if (is_array($viewsResultArray)) {
foreach ($viewsResultArray as $sqlRow) {
$ignoreTables[] = $sqlRow[0];
Expand Down Expand Up @@ -176,8 +176,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$tablesNoData = array_map('escapeshellarg', $tables);
$tablesNoData = implode(' ', $tablesNoData);

$commandOnlyTable = $this->getMysqlDumpCommand() . ' ' . $tablesNoData;
$commandOnlyTable = sprintf($commandOnlyTable, ' --no-data');
$commandOnlyTable = $this->getMysqlDumpCommand('--no-data') . ' ' . $tablesNoData;
if ($file) {
$commandOnlyTable .= " > $file";
}
Expand All @@ -191,8 +190,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$ignoreTables = implode(' ', $ignoreTables);

$commandTable = $this->getMysqlDumpCommand();
$commandTable = sprintf($commandTable, $ignoreTables);
$commandTable = $this->getMysqlDumpCommand($ignoreTables);
if (!empty($explicatedTable)) {
$explicatedTable = array_map('escapeshellarg', $explicatedTable);
$commandTable .= implode(' ', $explicatedTable);
Expand Down Expand Up @@ -224,17 +222,19 @@ protected function execute(InputInterface $input, OutputInterface $output)
/**
* Get the mysqldump cli command with user credentials.
*
* @param string $arguments
* @return string
*/
protected function getMysqlDumpCommand()
protected function getMysqlDumpCommand($arguments = '')
{
$dbHost = \oxRegistry::getConfig()->getConfigParam('dbHost');
$dbPort = \oxRegistry::getConfig()->getConfigParam('dbPort');
$dbUser = \oxRegistry::getConfig()->getConfigParam('dbUser');
$dbName = \oxRegistry::getConfig()->getConfigParam('dbName');

$dbPwd = \oxRegistry::getConfig()->getConfigParam('dbPwd');
if (!empty($dbPwd)) {
$dbPwd = ' -p' . $dbPwd;
$dbPwd = ' -p' . escapeshellarg($dbPwd);
}

$utfMode = '';
Expand All @@ -245,13 +245,14 @@ protected function getMysqlDumpCommand()
$mysqldump = 'mysqldump' .
' -u ' . escapeshellarg($dbUser) .
' -h ' . escapeshellarg($dbHost) .
' -P ' . escapeshellarg($dbPort) .
$dbPwd .
' --force' .
' --quick' .
' --opt' .
' --hex-blob' .
$utfMode .
' %s ' . # argumment part
$utfMode . ' ' .
$arguments . ' ' .
$dbName .
' '; # bash part

Expand Down Expand Up @@ -302,17 +303,17 @@ protected function filterValidTables($tables)
}

$whereIN = implode("', '", $whereIN);
$conditionsIN = "Tables_in_{$dbName} IN ('{$whereIN}')";
$conditionsIN = "`Tables_in_{$dbName}` IN ('{$whereIN}')";

$conditionsLIKE = '';
if (!empty($whereLIKE)) {
$template = " OR Tables_in_{$dbName} LIKE ('%s')";
$template = " OR `Tables_in_{$dbName}` LIKE ('%s')";
foreach ($whereLIKE as $tablename) {
$conditionsLIKE .= sprintf($template, $tablename);
}
}

$sqlstament = "SHOW FULL TABLES IN {$dbName} WHERE $conditionsIN $conditionsLIKE";
$sqlstament = "SHOW FULL TABLES IN `{$dbName}` WHERE $conditionsIN $conditionsLIKE";

$result = \oxDb::getDb()->getAll($sqlstament);

Expand Down
5 changes: 3 additions & 2 deletions src/Oxrun/Command/Database/ImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
// allow empty password
$dbPwd = Registry::getConfig()->getConfigParam('dbPwd');
if (!empty($dbPwd)) {
$dbPwd = '-p' . $dbPwd;
$dbPwd = '-p' . escapeshellarg($dbPwd);
}

$exec = sprintf(
"mysql -h%s %s -u%s %s < %s 2>&1",
"mysql -h%s -P%s %s -u%s %s < %s 2>&1",
Registry::getConfig()->getConfigParam('dbHost'),
Registry::getConfig()->getConfigParam('dbPort'),
$dbPwd,
Registry::getConfig()->getConfigParam('dbUser'),
Registry::getConfig()->getConfigParam('dbName'),
Expand Down
6 changes: 3 additions & 3 deletions src/Oxrun/Command/Database/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,17 @@ protected function filterValidTables($tables)
}

$whereIN = implode("', '", $whereIN);
$conditionsIN = "Tables_in_{$dbName} IN ('{$whereIN}')";
$conditionsIN = "`Tables_in_{$dbName}` IN ('{$whereIN}')";

$conditionsLIKE = '';
if (!empty($whereLIKE)) {
$template = " OR Tables_in_{$dbName} LIKE ('%s')";
$template = " OR `Tables_in_{$dbName}` LIKE ('%s')";
foreach ($whereLIKE as $tablename) {
$conditionsLIKE .= sprintf($template, $tablename);
}
}

$sqlstament = "SHOW FULL TABLES IN {$dbName} WHERE $conditionsIN $conditionsLIKE";
$sqlstament = "SHOW FULL TABLES IN `{$dbName}` WHERE $conditionsIN $conditionsLIKE";

$existsTable = DatabaseProvider::getDb()->getAll($sqlstament);

Expand Down
5 changes: 3 additions & 2 deletions src/Oxrun/Command/Database/QueryCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
// allow empty password
$dbPwd = \oxRegistry::getConfig()->getConfigParam('dbPwd');
if (!empty($dbPwd)) {
$dbPwd = '-p' . $dbPwd;
$dbPwd = '-p' . escapeshellarg($dbPwd);
}

$exec = sprintf(
"mysql -h%s %s -u%s %s -e '%s' 2>&1",
"mysql -h%s -P%s %s -u%s %s -e '%s' 2>&1",
\oxRegistry::getConfig()->getConfigParam('dbHost'),
\oxRegistry::getConfig()->getConfigParam('dbPort'),
$dbPwd,
\oxRegistry::getConfig()->getConfigParam('dbUser'),
\oxRegistry::getConfig()->getConfigParam('dbName'),
Expand Down
44 changes: 23 additions & 21 deletions src/Oxrun/Command/Deploy/ConfigCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
$mallValues = Yaml::parse($mallYml);
} catch (\Exception $e) {
$this->output->getErrorOutput()->writeln('<error>' . $e->getMessage() . '</error>');
return 1;
return self::FAILURE;
}

if (empty($mallValues)) {
$this->output->getErrorOutput()->writeln('<error>File ' . $this->input->getArgument('configfile') . ' is broken.</error>');
return 1;
return self::FAILURE;
}

// Read Configration EnvironmentManager
Expand All @@ -153,10 +153,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->saveModuleConfigationYaml();
} else {
$this->output->getErrorOutput()->writeln('<error>No `config:` found in ' . $this->input->getArgument('configfile') . '</error>');
return 1;
return self::FAILURE;
}

return 0;
return self::SUCCESS;
}

/**
Expand Down Expand Up @@ -189,23 +189,25 @@ protected function setConfigurations($mallSettings)
}

if ($moduleId) {
list($devnull, $module) = explode(':', $moduleId);
if (empty($module)) {
$this->output->getErrorOutput()->writeln(sprintf(
'ModuleId not can not be detacted ShopId: %s, ModuleId: %s, VariableName: %s, VariableValue: %s',
$shopId, $moduleId, $varName, $varValue
));
}
$this->environments->set($shopId, $module, $varType, $varName, $varValue);
$this->isChangeModuleSettings = true;

$this->output->writeln(
"({$shopId}) Module Config <info>" . trim(trim(Yaml::dump([$varName => $varValue], 0, 1), '{}')) . "</info> will be saved"
);

//Default: Do not save module configs in the database.
if ($this->input->getOption('force-db') == false) {
continue;
list($type, $module) = explode(':', $moduleId);
if ($type === 'module') {
if (empty($module)) {
$this->output->getErrorOutput()->writeln(sprintf(
'ModuleId not can not be detacted ShopId: %s, ModuleId: %s, VariableName: %s, VariableValue: %s',
$shopId, $moduleId, $varName, $varValue
));
}
$this->environments->set($shopId, $module, $varType, $varName, $varValue);
$this->isChangeModuleSettings = true;

$this->output->writeln(
"({$shopId}) Module Config <info>" . trim(trim(Yaml::dump([$varName => $varValue], 0, 1), '{}')) . "</info> will be saved"
);

//Default: Do not save module configs in the database.
if ($this->input->getOption('force-db') == false) {
continue;
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/Oxrun/Command/Deploy/GenerateConfigurationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Yaml\Yaml;
use Webmozart\PathUtil\Path;
use Symfony\Component\Filesystem\Path;

/**
* Class GenerateYamlMultiSetCommand
Expand Down Expand Up @@ -152,7 +152,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

if ($input->getOption('list')) {
$this->listfolder($output);
return 0;
return self::SUCCESS;
}

$this->environments->init($input, $output);
Expand Down Expand Up @@ -194,7 +194,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->fileStorage->save($path, $yamltxt);

$output->writeln("<comment>Config saved. use `oe-console deploy:config " . $input->getOption('configfile') . "`</comment>");
return 0;
return self::SUCCESS;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Oxrun/Command/Deploy/GenerateModuleActivatorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
file_put_contents($path, Yaml::dump($yaml, 5, 2));

$output->writeln("<comment>Module saved use `oe-console deploy:module-activator ".basename($path)."`</comment>");

return self::SUCCESS;
}

/**
Expand Down
Loading

0 comments on commit 102af40

Please sign in to comment.