Skip to content

Commit

Permalink
Merge branch 'release/1.97.21'
Browse files Browse the repository at this point in the history
  • Loading branch information
ktomk committed May 8, 2016
2 parents 2454a87 + 3a64839 commit 540363d
Show file tree
Hide file tree
Showing 12 changed files with 347 additions and 84 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
RECENT CHANGES
==============

1.97.21
-------

* Fix: codePool header regression in 1.97.20(reported by Jeroen Boersma)

1.97.20
-------

Expand Down
19 changes: 9 additions & 10 deletions build/local/test_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ IFS=$'\n\t'

buildecho()
{
echo -en "\e[44m[TEST-SETUP]\e[49m "
echo -en "\e[1;44;97m[TEST-SETUP]\e[0m "
echo "${1}"
}

Expand Down Expand Up @@ -52,27 +52,24 @@ ensure_environment() {
buildecho "directory: '${directory}'"
}

# create mysql database ($1) if it does not yet exists
# create mysql database if it does not yet exists
ensure_mysql_db() {
local db_host="${test_setup_db_host}"
local db_port="${test_setup_db_port}"
local db_user="${test_setup_db_user}"
local db_pass="${test_setup_db_pass}"
local db_name="${test_setup_db_name}"


if [ "" == "${db_pass}" ]; then
mysql -u"${db_user}" -h"${db_host}" -e "CREATE DATABASE IF NOT EXISTS \`${db_name}\`;"
else
mysql -u"${db_user}" -p"${db_pass}" -h"${db_host}" -e "'CREATE DATABASE IF NOT EXISTS \`${db_name}\`;'"
fi;
mysql -u"${db_user}" --password="${db_pass}" -h"${db_host}" -P"${db_port}" -e "CREATE DATABASE IF NOT EXISTS \`${db_name}\`;"

buildecho "mysql database: '${db_name}' (${db_user}@${db_host})"
}

# install into a directory ($1) a Magento version ($2) with or w/o sample-data ($3)
# install into a directory a Magento version with or w/o sample-data
ensure_magento() {
local directory="${test_setup_directory}"
local db_host="${test_setup_db_host}"
local db_port="${test_setup_db_port}"
local db_user="${test_setup_db_user}"
local db_pass="${test_setup_db_pass}"
local db_name="${test_setup_db_name}"
Expand All @@ -88,7 +85,8 @@ ensure_magento() {
else
php -dmemory_limit=1g -f "${magerun_cmd}" -- install \
--magentoVersionByName="${magento_version}" --installationFolder="${directory}" \
--dbHost="${db_host}" --dbUser="${db_user}" --dbPass="${db_pass}" --dbName="${db_name}" \
--dbHost="${db_host}" --dbPort="${db_port}" --dbUser="${db_user}" --dbPass="${db_pass}" \
--dbName="${db_name}" \
--installSampleData="${install_sample_data}" --useDefaultConfigParams=yes \
--baseUrl="http://dev.magento.local/"
buildecho "magento version '${magento_version}' installed."
Expand All @@ -99,6 +97,7 @@ test_setup_basename="n98-magerun"
test_setup_magerun_cmd="bin/${test_setup_basename}"
test_setup_directory="./magento/www"
test_setup_db_host="127.0.0.1"
test_setup_db_port="${test_setup_db_port:-3306}"
test_setup_db_user="root"
test_setup_db_pass=""
test_setup_db_name="magento_magerun_test"
Expand Down
2 changes: 1 addition & 1 deletion src/N98/Magento/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Application extends BaseApplication
/**
* @var string
*/
const APP_VERSION = '1.97.20';
const APP_VERSION = '1.97.21';

/**
* @var int
Expand Down
9 changes: 3 additions & 6 deletions src/N98/Magento/Command/AbstractMagentoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Composer\Package\PackageInterface;
use InvalidArgumentException;
use N98\Util\OperatingSystem;
use N98\Util\StringTyped;
use RuntimeException;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -414,7 +415,7 @@ protected function _getResourceSingleton($mage1code, $mage2class)
*/
protected function _parseBoolOption($value)
{
return in_array(strtolower($value), array('y', 'yes', 1, 'true'));
return StringTyped::parseBoolOption($value);
}

/**
Expand All @@ -423,11 +424,7 @@ protected function _parseBoolOption($value)
*/
protected function formatActive($value)
{
if (in_array($value, array(1, 'true'))) {
return 'active';
}

return 'inactive';
return StringTyped::formatActive($value);
}

/**
Expand Down
60 changes: 12 additions & 48 deletions src/N98/Magento/Command/Developer/Module/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

namespace N98\Magento\Command\Developer\Module;

use Mage;
use N98\Magento\Command\AbstractMagentoCommand;
use N98\Util\ArrayFunctions;
use N98\Magento\Modules;
use N98\Util\Console\Helper\Table\Renderer\RendererFactory;
use N98\Util\Console\Helper\TableHelper;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -44,66 +43,31 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->writeSection($output, 'Magento Modules');
}
$this->initMagento();
$modules = $this->findInstalledModules();
$modules = $this->filterModules($modules, $input);

if (empty($modules)) {
$output->writeln("No modules match the specified criteria.");
$modules = $this->filterModules($input);

if (!count($modules)) {
$output->writeln("No modules match the specified criteria.");
return;
}

/** @var TableHelper $table */
$table = $this->getHelper('table');
$table
->setHeaders(array('Code pool', 'Name', 'Version', 'Status'))
->renderByFormat($output, $modules, $input->getOption('format'));
->setHeaders(array('codePool', 'Name', 'Version', 'Status'))
->renderByFormat($output, iterator_to_array($modules), $input->getOption('format'));
}

/**
* @return array
*/
private function findInstalledModules()
{
$return = array();

$modules = Mage::app()->getConfig()->getNode('modules')->asArray();
foreach ($modules as $moduleName => $moduleInfo) {
$codePool = isset($moduleInfo['codePool']) ? $moduleInfo['codePool'] : '';
$version = isset($moduleInfo['version']) ? $moduleInfo['version'] : '';
$active = isset($moduleInfo['active']) ? $moduleInfo['active'] : '';

$return[] = array(
'Code pool' => trim($codePool),
'Name' => trim($moduleName),
'Version' => trim($version),
'Status' => $this->formatActive($active),
);
}

return $return;
}

/**
* Filter modules by codepool, status and vendor if such options were inputted by user
*
* @param array $modules
* @param InputInterface $input
* @return array
*
* @return Modules
*/
private function filterModules(array $modules, InputInterface $input)
private function filterModules(InputInterface $input)
{
if ($input->getOption('codepool')) {
$modules = ArrayFunctions::matrixFilterByValue($modules, "codePool", $input->getOption('codepool'));
}

if ($input->getOption('status')) {
$modules = ArrayFunctions::matrixFilterByValue($modules, 'Status', $input->getOption('status'));
}

if ($input->getOption('vendor')) {
$modules = ArrayFunctions::matrixFilterStartswith($modules, 'Name', $input->getOption('vendor'));
}
$modules = new Modules();
$modules = $modules->findInstalledModules()
->filterModules($input);

return $modules;
}
Expand Down
45 changes: 29 additions & 16 deletions src/N98/Magento/Command/Installer/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,19 +505,23 @@ protected function validateDatabaseSettings(OutputInterface $output, InputInterf

return $db;
}

if ($input->getOption('noDownload') && !$input->getOption('forceUseDb')) {
$output->writeln("<error>Database {$this->config['db_name']} already exists.</error>");

return false;
}

return $db;
} catch (PDOException $e) {
$output->writeln('<error>' . $e->getMessage() . '</error>');
return false;
}

if ($input->getOption('noDownload') && !$input->getOption('forceUseDb')) {
$output->writeln(
sprintf(
"<error>Database '%s' already exists, use --forceUseDb in combination with --noDownload" .
" to use an existing database</error>",
$this->config['db_name']
)
);
return false;
}

return false;
return $db;
}

/**
Expand Down Expand Up @@ -660,6 +664,7 @@ protected function removeEmptyFolders()
protected function installMagento(InputInterface $input, OutputInterface $output)
{
$this->getApplication()->setAutoExit(false);
/** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */
$dialog = $this->getHelperSet()->get('dialog');

$defaults = $this->commandConfig['installation']['defaults'];
Expand Down Expand Up @@ -754,7 +759,9 @@ protected function installMagento(InputInterface $input, OutputInterface $output

$validateBaseUrl = function ($input) {
if (!preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $input)) {
throw new InvalidArgumentException('Please enter a valid URL');
throw new InvalidArgumentException(
sprintf('Invalid URL %s. Please enter a valid URL', var_export($input, true))
);
}
if (parse_url($input, \PHP_URL_HOST) == 'localhost') {
throw new InvalidArgumentException(
Expand All @@ -765,12 +772,18 @@ protected function installMagento(InputInterface $input, OutputInterface $output
return $input;
};

$baseUrl = ($input->getOption('baseUrl') !== null) ? $input->getOption('baseUrl') : $dialog->askAndValidate(
$output,
'<question>Please enter the base url:</question> ',
$validateBaseUrl,
false
);
$baseUrl = $input->getOption('baseUrl');
if (null === $baseUrl) {
if (!$input->isInteractive()) {
throw new InvalidArgumentException('Installation base url is mandatory, use --baseUrl.');
}
$baseUrl = $dialog->askAndValidate(
$output,
'<question>Please enter the base url:</question> ',
$validateBaseUrl
);
}
$validateBaseUrl($baseUrl);
$baseUrl = rtrim($baseUrl, '/') . '/'; // normalize baseUrl

/**
Expand Down
5 changes: 3 additions & 2 deletions src/N98/Magento/Command/System/Cron/RunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$runConfig = $jobConfig->run;

if ($runConfig->model) {
if (!preg_match(self::REGEX_RUN_MODEL, (string) $runConfig->model, $run)) {
if (!preg_match(self::REGEX_RUN_MODEL, (string)$runConfig->model, $run)) {
throw new RuntimeException('Invalid model/method definition, expecting "model/class::method".');
}
$model = \Mage::getModel($run[1]);
Expand Down Expand Up @@ -110,7 +110,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

/**
* @param OutputInterface $output
* @param array $jobs array of array containing "job" keyed string entries of job-codes
* @param array $jobs array of array containing "job" keyed string entries of job-codes
*
* @return string job-code
* @throws InvalidArgumentException when user selects invalid job interactively
Expand All @@ -136,6 +136,7 @@ function ($typeInput) use ($keyMap, $jobs) {
if (!isset($jobs[$key])) {
throw new InvalidArgumentException('Invalid job');
}

return $jobs[$key]['Job'];
}
);
Expand Down
Loading

0 comments on commit 540363d

Please sign in to comment.