Skip to content

Commit

Permalink
Merge branch 'release/1.97.17'
Browse files Browse the repository at this point in the history
  • Loading branch information
ktomk committed Apr 9, 2016
2 parents 0c8d1b9 + 98934b5 commit 0c71fb6
Show file tree
Hide file tree
Showing 16 changed files with 305 additions and 225 deletions.
2 changes: 1 addition & 1 deletion bin/n98-magerun
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
$application = require __DIR__.'/../src/bootstrap.php';
$application->run();

__HALT_COMPILER();
__halt_compiler();
23 changes: 11 additions & 12 deletions build/bin/files.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
]
JSON_URLS;

$urlHeaders = function($url) {
return function($name = null) use ($url) {
$urlHeaders = function ($url) {
return function ($name = null) use ($url) {
static $response;
$response || $response = shell_exec(sprintf('curl -sI %s', escapeshellarg($url)));

Expand All @@ -35,28 +35,28 @@
};
};

$box = function($title) {
$len = strlen($title);
$box = function ($title) {
$len = strlen($title);
$buffer = str_repeat("=", $len + 4);
$buffer .= "\n= $title =\n";
$buffer .= str_repeat("=", $len + 4);

return $buffer . "\n";
};

$bytes = function($count) {
$bytes = function ($count) {
return sprintf('%s (bytes)', number_format($count, 0, '.', ' '));
};

$urls = json_decode($urls, false, 16, null);

$main = function($urls) use ($urlHeaders, $box, $bytes)
{
$main = function ($urls) use ($urlHeaders, $box, $bytes) {
foreach ($urls as $url) {
$title = sprintf("%s: %s", $url->channel, $url->url);
echo $box($title);

$headers = $urlHeaders($url->url);
printf("Status..: %s\n", $headers(TRUE));
printf("Status..: %s\n", $headers(true));
printf("Size....: %s\n", $bytes($headers('Content-Length')));
printf("Modified: %s\n", $headers('Last-Modified'));

Expand All @@ -71,10 +71,9 @@
unlink($tempFile);
}
file_put_contents($tempFile, fopen($url->url, 'r'));
printf(
"%'.-8s: %s\n MD5.: %s\n", ucfirst($url->channel), rtrim(`php -f "{$tempFile}" -- --no-ansi --version`),
md5_file($tempFile, false)
);
$magerunVersion = rtrim(`php -f "{$tempFile}" -- --no-ansi --version`);
$md5File = md5_file($tempFile, false);
printf("%'.-8s: %s\n MD5.: %s\n", ucfirst($url->channel), $magerunVersion, $md5File);
clearstatcache(null, $tempFile);
printf(" Size: %s\n", $bytes(filesize($tempFile)));
unlink($tempFile);
Expand Down
31 changes: 12 additions & 19 deletions build/local/test_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ installed_magerun_cmd() {
echo "${magerun_cmd}"
}

# obtain installed vesion of the test-setup
# obtain installed version of the test-setup
installed_version() {
local magerun_cmd="$(installed_magerun_cmd)"
local directory="${test_setup_directory}"
Expand All @@ -35,7 +35,7 @@ installed_version() {
fi
}

# checks befor starting the setup
# checks before starting the setup
ensure_environment() {
local magerun_cmd="$(installed_magerun_cmd)"
local directory="${test_setup_directory}"
Expand All @@ -44,6 +44,10 @@ ensure_environment() {

if [ ! -d "${directory}" ]; then
mkdir -p "${directory}"
# create .gitignore one-up if it does not yet exists to allow having the install within an existing git repo
if [ ! -e "${directory}/../.gitignore" ]; then
echo "*" > "${directory}/../.gitignore"
fi
fi;
buildecho "directory: '${directory}'"
}
Expand Down Expand Up @@ -77,11 +81,9 @@ ensure_magento() {
local install_sample_data="${2:-no}"

local magerun_cmd="${test_setup_magerun_cmd}"
local version="$(installed_version)"

local magento_local_xml="${directory}/app/etc/local.xml"

if [ -e "${magento_local_xml}" ]; then
local version="$(php -dmemory_limit=1g -f "${magerun_cmd}" -- --root-dir="${directory}" sys:info -- "version")"
if [ "" != "$version" ]; then
buildecho "version '${version}' already installed, skipping setup"
else
php -dmemory_limit=1g -f "${magerun_cmd}" -- install \
Expand All @@ -90,14 +92,6 @@ ensure_magento() {
--installSampleData="${install_sample_data}" --useDefaultConfigParams=yes \
--baseUrl="http://dev.magento.local/"
buildecho "magento version '${magento_version}' installed."

# automatically ignore the test installation directory as this is a local and interactive development env
local gitignore="${directory}/.gitignore"
if [ ! -e "${gitignore}" ]; then
touch "${gitignore}"
fi

echo '*' > "${gitignore}"
fi
}

Expand All @@ -111,11 +105,10 @@ test_setup_db_name="magento_magerun_test"

if [ "" != "$(installed_version)" ]; then
buildecho "version '$(installed_version)' already installed, skipping setup"
exit 0
else
ensure_environment
ensure_mysql_db
ensure_magento "magento-mirror-1.9.2.3"
fi

ensure_environment
ensure_mysql_db
ensure_magento "magento-mirror-1.9.2.3"

buildecho "export N98_MAGERUN_TEST_MAGENTO_ROOT='${test_setup_directory}'"
7 changes: 7 additions & 0 deletions changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
RECENT CHANGES
**************

=======
1.97.17
=======

* Fix: Fix module loader (reported by Matthias Walter, fixed by TK)
* #805 Fix config:delete (by Tom Klingenberg)

=======
1.97.16
=======
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 @@ -37,7 +37,7 @@ class Application extends BaseApplication
/**
* @var string
*/
const APP_VERSION = '1.97.16';
const APP_VERSION = '1.97.17';

/**
* @var int
Expand Down
14 changes: 8 additions & 6 deletions src/N98/Magento/Application/ConfigurationLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,15 @@ public function loadPluginConfig($config, $magentoRootFolder)
if ($this->_pluginConfig == null) {
$this->_pluginConfig = array();
$moduleBaseFolders = array();
$customFilename = $this->_customConfigFilename;
$customName = pathinfo($customFilename, PATHINFO_FILENAME);
if (OperatingSystem::isWindows()) {
$config['plugin']['folders'][] = getenv('WINDIR') . '/n98-magerun/modules';
$config['plugin']['folders'][] = OperatingSystem::getHomeDir() . '/n98-magerun/modules';
$config['plugin']['folders'][] = getenv('WINDIR') . '/' . $customName . '/modules';
$config['plugin']['folders'][] = OperatingSystem::getHomeDir() . '/' . $customName . '/modules';
} else {
$config['plugin']['folders'][] = OperatingSystem::getHomeDir() . '/.n98-magerun/modules';
$config['plugin']['folders'][] = OperatingSystem::getHomeDir() . '/.' . $customName . '/modules';
}
$config['plugin']['folders'][] = $magentoRootFolder . '/lib/n98-magerun/modules';
$config['plugin']['folders'][] = $magentoRootFolder . '/lib/' . $customName . '/modules';
foreach ($config['plugin']['folders'] as $folder) {
if (is_dir($folder)) {
$moduleBaseFolders[] = $folder;
Expand All @@ -238,7 +240,7 @@ public function loadPluginConfig($config, $magentoRootFolder)
->depth(2)
->followLinks()
->ignoreUnreadableDirs(true)
->name($this->_customConfigFilename)
->name($customFilename)
->in($this->getVendorDir());

foreach ($finder as $file) {
Expand All @@ -256,7 +258,7 @@ public function loadPluginConfig($config, $magentoRootFolder)
->depth(1)
->followLinks()
->ignoreUnreadableDirs(true)
->name($this->_customConfigFilename)
->name($customFilename)
->in($moduleBaseFolders);

foreach ($finder as $file) {
Expand Down
47 changes: 43 additions & 4 deletions src/N98/Magento/Command/Config/AbstractConfigCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@

abstract class AbstractConfigCommand extends AbstractMagentoCommand
{
/**
* @var array strings of configuration scopes
*/
protected $_scopes = array(
'default',
'websites',
'stores',
);

/**
* @return \Mage_Core_Model_Encryption
*/
Expand Down Expand Up @@ -45,28 +54,44 @@ protected function _formatValue($value, $encryptionType)

/**
* @param string $scope
*
* @return string
*/
protected function _validateScopeParam($scope)
{
if (!in_array($scope, $this->_scopes)) {
throw new InvalidArgumentException(
'Invalid scope parameter. It must be one of ' . implode(',', $this->_scopes)
sprintf('Invalid scope parameter, must be one of: %s.', implode(', ', $this->_scopes))
);
}

return $scope;
}

/**
* @param string $scope
* @param string $scopeId
*
* @return string
* @return string non-negative integer number
*/
protected function _convertScopeIdParam($scope, $scopeId)
{
if ($scope === 'default') {
if ("$scopeId" !== "0") {
throw new InvalidArgumentException(
sprintf("Invalid scope ID %d in scope '%s', must be 0", $scopeId, $scope)
);
}

return $scopeId;
}

if ($scope == 'websites' && !is_numeric($scopeId)) {
$website = \Mage::app()->getWebsite($scopeId);
if (!$website) {
throw new InvalidArgumentException('Invalid scope parameter. Website does not exist.');
throw new InvalidArgumentException(
sprintf("Invalid scope parameter, website '%s' does not exist.", $scopeId)
);
}

return $website->getId();
Expand All @@ -75,12 +100,26 @@ protected function _convertScopeIdParam($scope, $scopeId)
if ($scope == 'stores' && !is_numeric($scopeId)) {
$store = \Mage::app()->getStore($scopeId);
if (!$store) {
throw new InvalidArgumentException('Invalid scope parameter. Store does not exist.');
throw new InvalidArgumentException(
sprintf("Invalid scope parameter. store '%s' does not exist.", $scopeId)
);
}

return $store->getId();
}

if ($scopeId !== (string)(int)$scopeId) {
throw new InvalidArgumentException(
sprintf("Invalid scope parameter, %s is not an integer value", var_export($scopeId, true))
);
}

if (0 >= (int)$scopeId) {
throw new InvalidArgumentException(
sprintf("Invalid scope parameter, %s is not a positive integer value", var_export($scopeId, true))
);
}

return $scopeId;
}

Expand Down
Loading

0 comments on commit 0c71fb6

Please sign in to comment.