Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/mainline/develop' into API-Bug-PR
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Paliarush committed Nov 4, 2015
2 parents 16c0ade + 9c1711b commit 75aec40
Show file tree
Hide file tree
Showing 12 changed files with 130 additions and 50 deletions.
4 changes: 3 additions & 1 deletion app/code/Magento/Cron/Observer/ProcessCronQueueObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ public function execute(\Magento\Framework\Event\Observer $observer)
$jobGroupsRoot = $this->_config->getJobs();

foreach ($jobGroupsRoot as $groupId => $jobsRoot) {
if ($this->_request->getParam('group') !== null && $this->_request->getParam('group') != $groupId) {
if ($this->_request->getParam('group') !== null
&& $this->_request->getParam('group') !== '\'' . ($groupId) . '\''
&& $this->_request->getParam('group') !== $groupId) {
continue;
}
if (($this->_request->getParam(self::STANDALONE_PROCESS_STARTED) !== '1') && (
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/App/Router/ActionList.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ActionList
/**
* Not allowed string in route's action path to avoid disclosing admin url
*/
const NOT_ALLOWED_IN_NAMESPACE_PATH = 'adminhtml_';
const NOT_ALLOWED_IN_NAMESPACE_PATH = 'adminhtml';

/**
* List of application actions
Expand Down
4 changes: 4 additions & 0 deletions lib/internal/Magento/Framework/Config/Dom.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ public static function validateDomDocument(
$schema,
$errorFormat = self::ERROR_FORMAT_DEFAULT
) {
if (!function_exists('libxml_set_external_entity_loader')) {
return [];
}

if (!self::$urnResolver) {
self::$urnResolver = new UrnResolver();
}
Expand Down
81 changes: 53 additions & 28 deletions lib/internal/Magento/Framework/Console/Cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
use Magento\Framework\App\Bootstrap;
use Magento\Framework\Shell\ComplexParameter;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
* Magento2 CLI Application. This is the hood for all command line tools supported by Magento.
Expand All @@ -27,6 +29,34 @@ class Cli extends SymfonyApplication
/** @var \Zend\ServiceManager\ServiceManager */
private $serviceManager;

/**
* Initialization exception
*
* @var \Exception
*/
private $initException;

/**
* Process an error happened during initialization of commands, if any
*
* @param InputInterface $input
* @param OutputInterface $output
* @return int
* @throws \Exception
*/
public function doRun(InputInterface $input, OutputInterface $output)
{
$exitCode = parent::doRun($input, $output);
if ($this->initException) {
$output->writeln(
"<error>We're sorry, an error occurred. Try clearing the cache and code generation directories. "
. "By default, they are: var/cache, var/di, var/generation, and var/page_cache.</error>"
);
throw $this->initException;
}
return $exitCode;
}

/**
* @param string $name The name of the application
* @param string $version The version of the application
Expand Down Expand Up @@ -61,38 +91,33 @@ protected function getDefaultCommands()
*/
protected function getApplicationCommands()
{
$setupCommands = [];
$modulesCommands = [];
$commands = [];
try {
$bootstrapParam = new ComplexParameter(self::INPUT_KEY_BOOTSTRAP);
$params = $bootstrapParam->mergeFromArgv($_SERVER, $_SERVER);
$params[Bootstrap::PARAM_REQUIRE_MAINTENANCE] = null;
$bootstrap = Bootstrap::create(BP, $params);
$objectManager = $bootstrap->getObjectManager();
/** @var \Magento\Setup\Model\ObjectManagerProvider $omProvider */
$omProvider = $this->serviceManager->get('Magento\Setup\Model\ObjectManagerProvider');
$omProvider->setObjectManager($objectManager);

$bootstrapParam = new ComplexParameter(self::INPUT_KEY_BOOTSTRAP);
$params = $bootstrapParam->mergeFromArgv($_SERVER, $_SERVER);
$params[Bootstrap::PARAM_REQUIRE_MAINTENANCE] = null;
$bootstrap = Bootstrap::create(BP, $params);
$objectManager = $bootstrap->getObjectManager();
/** @var \Magento\Setup\Model\ObjectManagerProvider $omProvider */
$omProvider = $this->serviceManager->get('Magento\Setup\Model\ObjectManagerProvider');
$omProvider->setObjectManager($objectManager);
if (class_exists('Magento\Setup\Console\CommandList')) {
$setupCommandList = new \Magento\Setup\Console\CommandList($this->serviceManager);
$commands = array_merge($commands, $setupCommandList->getCommands());
}

if (class_exists('Magento\Setup\Console\CommandList')) {
$setupCommandList = new \Magento\Setup\Console\CommandList($this->serviceManager);
$setupCommands = $setupCommandList->getCommands();
}
if ($objectManager->get('Magento\Framework\App\DeploymentConfig')->isAvailable()) {
/** @var \Magento\Framework\Console\CommandList $commandList */
$commandList = $objectManager->create('Magento\Framework\Console\CommandList');
$commands = array_merge($commands, $commandList->getCommands());
}

if ($objectManager->get('Magento\Framework\App\DeploymentConfig')->isAvailable()) {
/** @var \Magento\Framework\Console\CommandList $commandList */
$commandList = $objectManager->create('Magento\Framework\Console\CommandList');
$modulesCommands = $commandList->getCommands();
$commands = array_merge($commands, $this->getVendorCommands($objectManager));
} catch (\Exception $e) {
$this->initException = $e;
}

$vendorCommands = $this->getVendorCommands($objectManager);

$commandsList = array_merge(
$setupCommands,
$modulesCommands,
$vendorCommands
);

return $commandsList;
return $commands;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions nginx.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ location /update {
root $MAGE_ROOT;

location ~ ^/update/index.php {
fastcgi_split_path_info ^(/update/index.php)(/.+)$;
fastcgi_pass fastcgi_backend;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi_params;
}

Expand Down
9 changes: 6 additions & 3 deletions pub/cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@

require dirname(__DIR__) . '/app/bootstrap.php';

if ($_GET){
$opt = $_GET;
} else {
if (php_sapi_name() === 'cli'){
echo "You cannot run this from the command line." . PHP_EOL .
"Run \"php bin/magento cron:run\" instead." . PHP_EOL;
exit(1);
} else {
$opt = $_GET;
}

try {
if (empty($opt['group'])) {
$opt['group'] = 'default';
}
foreach ($opt as $key => $value) {
$opt[$key] = escapeshellarg($value);
}
$opt['standaloneProcessStarted'] = '0';
$params = $_SERVER;
$params[StoreManager::PARAM_RUN_CODE] = 'admin';
Expand Down
4 changes: 0 additions & 4 deletions setup/pub/magento/setup/component-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ angular.module('component-grid', ['ngStorage'])
$rootScope.componentsProcessed = false;
$http.get('index.php/componentGrid/components').success(function(data) {
$scope.components = data.components;
$scope.displayComponents = data.components;
$scope.total = data.total;
if(typeof data.lastSyncData.lastSyncDate === "undefined") {
$scope.isOutOfSync = true;
Expand All @@ -35,9 +34,6 @@ angular.module('component-grid', ['ngStorage'])
var begin = (($scope.currentPage - 1) * $scope.rowLimit);
var end = parseInt(begin) + parseInt(($scope.rowLimit));
$scope.numberOfPages = Math.ceil($scope.total/$scope.rowLimit);
if ($scope.components !== undefined) {
$scope.displayComponents = $scope.components.slice(begin, end);
}
if ($scope.currentPage > $scope.numberOfPages) {
$scope.currentPage = $scope.numberOfPages;
}
Expand Down
10 changes: 10 additions & 0 deletions setup/src/Magento/Setup/Controller/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,17 @@ public function progressAction()
{
$percent = 0;
$success = false;
$contents = [];
$json = new JsonModel();

// Depending upon the install environment and network latency, there is a possibility that
// "progress" check request may arrive before the Install POST request. In that case
// "install.log" file may not be created yet. Check the "install.log" is created before
// trying to read from it.
if (!$this->log->logfileExists()) {
return $json->setVariables(['progress' => $percent, 'success' => true, 'console' => $contents]);
}

try {
$progress = $this->progressFactory->createFromLog($this->log);
$percent = sprintf('%d', $progress->getRatio() * 100);
Expand Down
28 changes: 18 additions & 10 deletions setup/src/Magento/Setup/Model/FilePermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace Magento\Setup\Model;

use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Backup\Filesystem\Iterator\Filter;
use Magento\Framework\Filesystem;

class FilePermissions
Expand Down Expand Up @@ -118,25 +119,32 @@ public function getInstallationCurrentWritableDirectories()
}

/**
* Check all sub-directories
* Check all sub-directories and files except for var/generation and var/di
*
* @param string $directory
* @return bool
*/
private function checkRecursiveDirectories($directory)
{
$skipDirs = ['..', '.'];
$directoryIterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($directory),
\RecursiveIteratorIterator::LEAVES_ONLY | \RecursiveIteratorIterator::CATCH_GET_CHILD
new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS),
\RecursiveIteratorIterator::CHILD_FIRST
);
foreach ($directoryIterator as $subDirectory) {
if (in_array($subDirectory->getFilename(), $skipDirs)) {
continue;
}
if ($subDirectory->isDir() && !$subDirectory->isWritable()) {
return false;
$noWritableFilesFolders = [
$this->directoryList->getPath(DirectoryList::GENERATION) . '/',
$this->directoryList->getPath(DirectoryList::DI) .'/'
];

$directoryIterator = new Filter($directoryIterator, $noWritableFilesFolders);

try {
foreach ($directoryIterator as $subDirectory) {
if (!$subDirectory->isWritable()) {
return false;
}
}
} catch (\UnexpectedValueException $e) {
return false;
}
return true;
}
Expand Down
10 changes: 10 additions & 0 deletions setup/src/Magento/Setup/Model/WebLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ public function clear()
}
}

/**
* Checks existence of install.log file
*
* @return bool
*/
public function logfileExists()
{
return ($this->directory->isExist($this->logFile));
}

/**
* Terminates line if the inline logging is started
*
Expand Down
18 changes: 18 additions & 0 deletions setup/src/Magento/Setup/Test/Unit/Controller/InstallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function setUp()
$this->installer = $this->getMock('\Magento\Setup\Model\Installer', [], [], '', false);
$this->progressFactory = $this->getMock('\Magento\Setup\Model\Installer\ProgressFactory', [], [], '', false);
$this->sampleDataState = $this->getMock('\Magento\Framework\Setup\SampleData\State', [], [], '', false);

$installerFactory->expects($this->once())->method('create')->with($this->webLogger)
->willReturn($this->installer);
$this->controller = new Install(
Expand Down Expand Up @@ -100,6 +101,8 @@ public function testProgressAction()
{
$numValue = 42;
$consoleMessages = ['key1' => 'log message 1', 'key2' => 'log message 2'];

$this->webLogger->expects($this->once())->method('logfileExists')->willReturn(true);
$progress = $this->getMock('\Magento\Setup\Model\Installer\Progress', [], [], '', false);
$this->progressFactory->expects($this->once())->method('createFromLog')->with($this->webLogger)
->willReturn($progress);
Expand All @@ -119,6 +122,7 @@ public function testProgressAction()
public function testProgressActionWithError()
{
$e = 'Some exception message';
$this->webLogger->expects($this->once())->method('logfileExists')->willReturn(true);
$this->progressFactory->expects($this->once())->method('createFromLog')
->will($this->throwException(new \LogicException($e)));
$jsonModel = $this->controller->progressAction();
Expand All @@ -134,6 +138,7 @@ public function testProgressActionWithError()
public function testProgressActionWithSampleDataError()
{
$numValue = 42;
$this->webLogger->expects($this->once())->method('logfileExists')->willReturn(true);
$progress = $this->getMock('\Magento\Setup\Model\Installer\Progress', [], [], '', false);
$progress->expects($this->once())->method('getRatio')->willReturn($numValue);
$this->progressFactory->expects($this->once())->method('createFromLog')->willReturn($progress);
Expand All @@ -148,6 +153,19 @@ public function testProgressActionWithSampleDataError()
$this->assertSame(sprintf('%d', $numValue * 100), $variables['progress']);
}

public function testProgressActionNoInstallLogFile()
{
$this->webLogger->expects($this->once())->method('logfileExists')->willReturn(false);
$jsonModel = $this->controller->progressAction();
$this->assertInstanceOf('\Zend\View\Model\JsonModel', $jsonModel);
$variables = $jsonModel->getVariables();
$this->assertArrayHasKey('success', $variables);
$this->assertArrayHasKey('console', $variables);
$this->assertTrue($variables['success']);
$this->assertEmpty($variables['console']);
$this->assertSame(0, $variables['progress']);
}

public function testDispatch()
{
$request = $this->getMock('\Zend\Http\PhpEnvironment\Request', [], [], '', false);
Expand Down
8 changes: 5 additions & 3 deletions setup/view/magento/setup/component-grid.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@
</tr>
</thead>
<tbody>
<tr ng-repeat="component in displayComponents | orderBy:predicate:reverse | limitTo:rowLimit">
<tr ng-repeat="component in components | orderBy:predicate:reverse
| startFrom:(currentPage - 1) * rowLimit | limitTo:rowLimit"
>
<td class="data-grid-indicator-cell">
<span class="component-indicator"
ng-class="getIndicatorInfo(component, 'icon')"
Expand Down Expand Up @@ -171,8 +173,8 @@
<!-- wrapper and .action-menu to show actions -->
<div class="action-select-wrap" ng-class="{'_active' : isActiveActionsCell(component)}">
<button class="action-select"
ng-show="component.update || component.uninstall ||
!component.disable || !component.update"
ng-show="isAvailableUpdatePackage(component.name) || component.uninstall ||
component.enable || component.disable"
ng-click="toggleActiveActionsCell(component)"
ng-blur="closeActiveActionsCell(component)">
<span>Select</span>
Expand Down

0 comments on commit 75aec40

Please sign in to comment.