Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/app/CliTools/Console/Command/Mysql/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

use CliTools\Console\Command\Traits\ClisyncConfigTrait;
use CliTools\Database\DatabaseConnection;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

abstract class AbstractCommand extends \CliTools\Console\Command\AbstractCommand
{
use ClisyncConfigTrait;

/**
* Configure command
Expand Down Expand Up @@ -85,6 +87,9 @@ protected function initialize(InputInterface $input, OutputInterface $output)
{
parent::initialize($input, $output);

// Try to read credentials from clisync.yml if present
$this->initDatabaseConfigurationFromClisync();

$dsn = null;
$user = null;
$password = null;
Expand Down
63 changes: 4 additions & 59 deletions src/app/CliTools/Console/Command/Sync/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

use CliTools\Console\Command\Traits\ClisyncConfigTrait;
use CliTools\Database\DatabaseConnection;
use CliTools\Reader\ConfigReader;
use CliTools\Shell\CommandBuilder\CommandBuilder;
Expand All @@ -29,7 +30,6 @@
use CliTools\Shell\CommandBuilder\RemoteCommandBuilder;
use CliTools\Shell\CommandBuilder\SelfCommandBuilder;
use CliTools\Utility\ConsoleUtility;
use CliTools\Utility\DockerUtility;
use CliTools\Utility\FilterUtility;
use CliTools\Utility\PhpUtility;
use CliTools\Utility\UnixUtility;
Expand All @@ -43,6 +43,7 @@

abstract class AbstractCommand extends \CliTools\Console\Command\AbstractDockerCommand
{
use ClisyncConfigTrait;

const CONFIG_FILE = 'clisync.yml';
const GLOBAL_KEY = 'GLOBAL';
Expand Down Expand Up @@ -155,64 +156,8 @@ protected function initializeConfiguration()
// Read configuration
$this->readConfiguration();

$this->initDatabaseConfiguration();
$this->initDockerContainer();
}

/**
* Init database configuration (for local one)
*/
protected function initDatabaseConfiguration()
{
$hostname = DatabaseConnection::getDbHostname();
$port = DatabaseConnection::getDbPort();
$username = DatabaseConnection::getDbUsername();
$password = DatabaseConnection::getDbPassword();

if ($this->config->exists('LOCAL.mysql.hostname')) {
$hostname = $this->config->get('LOCAL.mysql.hostname');
}

if ($this->config->exists('LOCAL.mysql.port')) {
$port = $this->config->get('LOCAL.mysql.port');
}

if ($this->config->exists('LOCAL.mysql.username')) {
$username = $this->config->get('LOCAL.mysql.username');
}

if ($this->config->exists('LOCAL.mysql.password')) {
$password = $this->config->get('LOCAL.mysql.password');
}

$dsn = 'mysql:host=' . urlencode($hostname) . ';port=' . (int)$port;

DatabaseConnection::setDsn($dsn, $username, $password);
}

/**
* Init docker container setting
*/
protected function initDockerContainer()
{
$useDockerMysql = false;

if ($this->config->exists('LOCAL.mysql.docker')) {
$this->setLocalDockerContainer(\CliTools\Console\Command\AbstractDockerCommand::DOCKER_ALIAS_MYSQL , $this->config->get('LOCAL.mysql.docker'));
$useDockerMysql = true;
} elseif ($this->config->exists('LOCAL.mysql.docker-compose')) {
$this->setLocalDockerContainer(\CliTools\Console\Command\AbstractDockerCommand::DOCKER_ALIAS_MYSQL , $this->config->get('LOCAL.mysql.docker-compose'), true);
$useDockerMysql = true;
}

if ($useDockerMysql) {
$container = $this->getLocalDockerContainer(\CliTools\Console\Command\AbstractDockerCommand::DOCKER_ALIAS_MYSQL);
$password = DockerUtility::getDockerContainerEnv($container, 'MYSQL_ROOT_PASSWORD');
if (empty($password)) {
$password = DockerUtility::getDockerContainerEnv($container, 'MARIADB_ROOT_PASSWORD');
}
DatabaseConnection::setDsn('mysql:host=localhost', 'root', $password);
}
// Init database and Docker configuration using trait (pass already loaded config)
$this->initDatabaseConfigurationFromClisync($this->config);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/app/CliTools/Console/Command/TYPO3/BeUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected function configure()
->addArgument(
'hash',
InputArgument::OPTIONAL,
'Choose the hashing algorithm for saving the password: md5, md5_salted, bcrypt, argon2i, argon2id'
'Choose the hashing algorithm for saving the password: bcrypt, argon2i, argon2id'
);
}

Expand Down Expand Up @@ -207,10 +207,11 @@ protected function setTypo3UserForDatabase($database, $username, $password)
$beUserId = reset($beUserId);

// Insert or update user in TYPO3 database
$uidValue = $beUserId ? $this->mysqlQuote($beUserId) : 'NULL';
$query = 'INSERT INTO ' . DatabaseConnection::sanitizeSqlDatabase($database) . '.be_users
(uid, tstamp, crdate, realName, username, password, TSconfig, admin, disable, starttime, endtime)
VALUES(
' . $this->mysqlQuote($beUserId) . ',
' . $uidValue . ',
UNIX_TIMESTAMP(),
UNIX_TIMESTAMP(),
' . $this->mysqlQuote('DEVELOPMENT') . ',
Expand Down
102 changes: 0 additions & 102 deletions src/app/CliTools/Console/Command/TYPO3/ClearCacheCommand.php

This file was deleted.

Loading