Skip to content

Commit

Permalink
Merge pull request #1628 from magento-engcom/2.1-develop-prs
Browse files Browse the repository at this point in the history
Public Pull Requests

#11761 [BACKPORT 2.1] [TASK] Incorrect minimum memory_limit references have … by @lewisvoncken
#11590 [Backport 2.1-develop] #11586 Fix duplicated crontab 2>&1 expression by @adrian-martinez-interactiv4

Fixed Public Issues

#11322 User.ini files specify 768M - Docs recommend at least 1G
#11586 Cron install / remove via command messes up stderr 2>&1 entries
  • Loading branch information
Oleksii Korshenko authored Oct 27, 2017
2 parents 05bb680 + 808aac1 commit 9adbca7
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# All explanations you could find in .htaccess.sample file
DirectoryIndex index.php
<IfModule mod_php5.c>
php_value memory_limit 768M
php_value memory_limit 756M
php_value max_execution_time 18000
php_flag session.auto_start off
php_flag suhosin.session.cryptua off
</IfModule>
<IfModule mod_php7.c>
php_value memory_limit 768M
php_value memory_limit 756M
php_value max_execution_time 18000
php_flag session.auto_start off
php_flag suhosin.session.cryptua off
Expand Down
4 changes: 2 additions & 2 deletions .htaccess.sample
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ DirectoryIndex index.php
############################################
## adjust memory limit

php_value memory_limit 768M
php_value memory_limit 756M
php_value max_execution_time 18000

############################################
Expand All @@ -59,7 +59,7 @@ DirectoryIndex index.php
############################################
## adjust memory limit

php_value memory_limit 768M
php_value memory_limit 756M
php_value max_execution_time 18000

############################################
Expand Down
2 changes: 1 addition & 1 deletion .user.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
memory_limit = 768M
memory_limit = 756M
max_execution_time = 18000
session.auto_start = off
suhosin.session.cryptua = off
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ private function updateMemoryLimit()
if (function_exists('ini_set')) {
@ini_set('display_errors', 1);
$memoryLimit = trim(ini_get('memory_limit'));
if ($memoryLimit != -1 && $this->getMemoryInBytes($memoryLimit) < 768 * 1024 * 1024) {
@ini_set('memory_limit', '768M');
if ($memoryLimit != -1 && $this->getMemoryInBytes($memoryLimit) < 756 * 1024 * 1024) {
@ini_set('memory_limit', '756M');
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions lib/internal/Magento/Framework/Shell/CommandRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ class CommandRenderer implements CommandRendererInterface
*/
public function render($command, array $arguments = [])
{
$command = preg_replace('/(\s+2>&1)*(\s*\|)|$/', ' 2>&1$2', $command);
$arguments = array_map('escapeshellarg', $arguments);
$command = preg_replace('/\s?\||$/', ' 2>&1$0', $command);
$command = vsprintf($command, $arguments);
return $command;
if (empty($arguments)) {
return $command;
}
return vsprintf($command, $arguments);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,40 @@
*/
namespace Magento\Framework\Shell\Test\Unit;

use \Magento\Framework\Shell\CommandRenderer;
use Magento\Framework\Shell\CommandRenderer;

class CommandRendererTest extends \PHPUnit_Framework_TestCase
{
public function testRender()
/**
* @param $expectedCommand
* @param $actualCommand
* @param $testArguments
* @dataProvider commandsDataProvider
*/
public function testRender($expectedCommand, $actualCommand, $testArguments)
{
$testArgument = 'argument';
$testArgument2 = 'argument2';
$commandRenderer = new CommandRenderer();
$this->assertEquals(
"php -r " . escapeshellarg($testArgument) . " 2>&1 | grep " . escapeshellarg($testArgument2) . " 2>&1",
$commandRenderer->render('php -r %s | grep %s', [$testArgument, $testArgument2])
$expectedCommand,
$commandRenderer->render($actualCommand, $testArguments)
);
}

public function commandsDataProvider()
{
$testArgument = 'argument';
$testArgument2 = 'argument2';

$expectedCommand = "php -r %s 2>&1 | grep %s 2>&1";
$expectedCommandArgs = "php -r '" . $testArgument . "' 2>&1 | grep '" . $testArgument2 . "' 2>&1";

return [
[$expectedCommand, 'php -r %s | grep %s', []],
[$expectedCommand, 'php -r %s 2>&1 | grep %s', []],
[$expectedCommand, 'php -r %s 2>&1 2>&1 | grep %s', []],
[$expectedCommandArgs, 'php -r %s | grep %s', [$testArgument, $testArgument2]],
[$expectedCommandArgs, 'php -r %s 2>&1 | grep %s', [$testArgument, $testArgument2]],
[$expectedCommandArgs, 'php -r %s 2>&1 2>&1 | grep %s', [$testArgument, $testArgument2]],
];
}
}
4 changes: 2 additions & 2 deletions pub/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
############################################
## Adjust memory limit

php_value memory_limit 768M
php_value memory_limit 756M
php_value max_execution_time 18000

############################################
Expand All @@ -59,7 +59,7 @@
############################################
## Adjust memory limit

php_value memory_limit 768M
php_value memory_limit 756M
php_value max_execution_time 18000

############################################
Expand Down
2 changes: 1 addition & 1 deletion pub/.user.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
memory_limit = 768M
memory_limit = 756M
max_execution_time = 18000
session.auto_start = off
suhosin.session.cryptua = off

0 comments on commit 9adbca7

Please sign in to comment.