Skip to content

Commit

Permalink
MAGETWO-33027: [GITHUB] Installation Incomplete with XDebug enabled #904
Browse files Browse the repository at this point in the history


- added check for xdebug.max_nesting_level
  • Loading branch information
Ivan Gavryshko committed Mar 16, 2015
1 parent 0c03986 commit 8a5f359
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 41 deletions.
14 changes: 7 additions & 7 deletions setup/pub/magento/setup/readiness-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ angular.module('readiness-check', [])
processed: false,
expanded: false
};
$scope.rawpost = {
$scope.settings = {
visible: false,
processed: false,
expanded: false
Expand Down Expand Up @@ -62,16 +62,16 @@ angular.module('readiness-check', [])
$scope.stopProgress();
}
},
'php-rawpost': {
url:'index.php/environment/php-rawpost',
'php-settings': {
url:'index.php/environment/php-settings',
show: function() {
$scope.startProgress();
$scope.rawpost.visible = true;
$scope.settings.visible = true;
},
process: function(data) {
$scope.rawpost.processed = true;
angular.extend($scope.rawpost, data);
$scope.updateOnProcessed($scope.rawpost.responseType);
$scope.settings.processed = true;
angular.extend($scope.settings, data);
$scope.updateOnProcessed($scope.settings.responseType);
$scope.stopProgress();
}
},
Expand Down
76 changes: 67 additions & 9 deletions setup/src/Magento/Setup/Controller/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,28 @@ public function phpVersionAction()
}

/**
* Checks if PHP version >= 5.6.0 and always_populate_raw_post_data is set
* Checks PHP settings
*
* @return JsonModel
*/
public function phpRawpostAction()
public function phpSettingsAction()
{
$iniSetting = ini_get('always_populate_raw_post_data');
$responseType = ResponseTypeInterface::RESPONSE_TYPE_SUCCESS;
if (version_compare(PHP_VERSION, '5.6.0') >= 0 && (int)$iniSetting > -1) {
$responseType = ResponseTypeInterface::RESPONSE_TYPE_ERROR;

$settings = array_merge(
$this->checkRawPost(),
$this->checkXDebugNestedLevel()
);

foreach ($settings as $setting) {
if ($setting['error']) {
$responseType = ResponseTypeInterface::RESPONSE_TYPE_ERROR;
}
}

$data = [
'responseType' => $responseType,
'data' => [
'version' => PHP_VERSION,
'ini' => ini_get('always_populate_raw_post_data')
]
'data' => $settings
];

return new JsonModel($data);
Expand Down Expand Up @@ -170,4 +175,57 @@ public function filePermissionsAction()

return new JsonModel($data);
}

/**
* Checks if PHP version >= 5.6.0 and always_populate_raw_post_data is set
*
* @return array
*/
private function checkRawPost()
{
$data = [];
$error = false;
$iniSetting = ini_get('always_populate_raw_post_data');

if (version_compare(PHP_VERSION, '5.6.0') >= 0 && (int)$iniSetting > -1) {
$error = true;
}

$data['rawpost'] = [
'version' => PHP_VERSION,
'ini' => ini_get('always_populate_raw_post_data'),
'error' => $error
];

return $data;
}

/**
* Checks if xdebug.max_nesting_level is set 200 or more
* @return array
*/
private function checkXDebugNestedLevel()
{
$data = [];
$error = false;

$currentExtensions = $this->phpInformation->getCurrent();
if (in_array('xdebug', $currentExtensions)) {

$currentXDebugNestingLevel = intval(ini_get('xdebug.max_nesting_level'));
$minimumRequiredXDebugNestedLevel = $this->phpInformation->getRequiredMinimumXDebugNestedLevel();

if ($minimumRequiredXDebugNestedLevel > $currentXDebugNestingLevel) {
$error = true;
}

$data['xdebug_max_nesting_level'] = [
'currentLevel' => $currentXDebugNestingLevel,
'requiredLevel' => $minimumRequiredXDebugNestedLevel,
'error' => $error
];
}

return $data;
}
}
15 changes: 15 additions & 0 deletions setup/src/Magento/Setup/Model/PhpInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@

class PhpInformation
{

/**
* Allowed XDebug nested level
*/
const XDEBUG_NESTED_LEVEL = 200;

/**
* List of required extensions
*
Expand Down Expand Up @@ -59,6 +65,15 @@ public function getRequiredPhpVersion()
}
}

/**
* Returns minimum required XDebug nested level
* @return int
*/
public function getRequiredMinimumXDebugNestedLevel()
{
return self::XDEBUG_NESTED_LEVEL;
}

/**
* Retrieve list of required extensions
*
Expand Down
61 changes: 36 additions & 25 deletions setup/view/magento/setup/readiness-check/progress.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
</a>
</p>
<p ng-show="version.expanded">
Donwload and install PHP version {{version.data.required}} from <a href="http://www.php.net" target="_blank">www.php.net</a> using this <a href="http://www.php.net/docs.php" target="_blank">PHP Documentation</a>.
Download and install PHP version {{version.data.required}} from <a href="http://www.php.net" target="_blank">www.php.net</a> using this <a href="http://www.php.net/docs.php" target="_blank">PHP Documentation</a>.
</p>
<p ng-show="version.expanded">If you need more help please call your hosting provider.</p>
</div>
Expand All @@ -86,15 +86,15 @@

</div>

<div id="php-rawpost" class="rediness-check-item" ng-show="rawpost.visible">
<div id="php-settings" class="rediness-check-item" ng-show="settings.visible">

<h3 class="readiness-check-title" ng-hide="version.processed">
<h3 class="readiness-check-title" ng-hide="settings.processed">
Checking PHP Settings...
</h3>

<div ng-show="rawpost.processed" ng-switch="rawpost.responseType">
<div ng-show="settings.processed" ng-switch="settings.responseType">

<div ng-switch-when="success" ng-init="updateOnSuccess(rawpost)">
<div ng-switch-when="success" ng-init="updateOnSuccess(settings)">

<span class="readiness-check-icon icon-success-round"></span>

Expand All @@ -107,29 +107,40 @@

</div>

<div class="readiness-check-item" ng-switch-default ng-init="updateOnError(rawpost)">

<div class="rediness-check-side">
<p class="side-title">Need Help?</p>
<a href="http://php.net/manual/en/ini.core.php#ini.always-populate-raw-post-data" target="_blank">PHP Documentation</a>
</div>
<div class="readiness-check-item" ng-switch-default ng-init="updateOnError(settings)">

<span class="readiness-check-icon icon-failed-round"></span>
<h3 class="readiness-check-title">PHP Settings Check</h3>

<div class="readiness-check-content">
<h3 class="readiness-check-title">PHP Settings Check</h3>
<p>
Your PHP Version is {{rawpost.data.version}}, but always_populate_raw_post_data = {{rawpost.data.ini}}.
<a href="#php-rawpost" ng-click="updateOnExpand(rawpost)">
<span ng-hide="rawpost.expanded">Show detail</span>
<span ng-show="rawpost.expanded">Hide detail</span>
</a>
</p>
<p ng-show="rawpost.expanded">
$HTTP_RAW_POST_DATA is deprecated from PHP 5.6 onwards and will stop the installer from running.
Please open your php.ini file and set always_populate_raw_post_data to -1.
</p>
<p ng-show="rawpost.expanded">If you need more help please call your hosting provider.</p>
<div ng-show="settings.data.rawpost.error">
<div class="rediness-check-side">
<p class="side-title">Need Help?</p>
<a href="http://php.net/manual/en/ini.core.php#ini.always-populate-settings-data" target="_blank">PHP Documentation</a>
</div>
<div class="readiness-check-content">

<p>
Your PHP Version is {{settings.data.rawpost.version}}, but always_populate_raw_post_data = {{settings.data.rawpost.ini}}.
<a href="#php-settings" ng-click="updateOnExpand(settings)">
<span ng-hide="settings.expanded">Show detail</span>
<span ng-show="settings.expanded">Hide detail</span>
</a>
</p>
<p ng-show="settings.expanded">
$HTTP_RAW_POST_DATA is deprecated from PHP 5.6 onwards and will stop the installer from running.
Please open your php.ini file and set always_populate_raw_post_data to -1.
</p>
<p ng-show="settings.expanded">If you need more help please call your hosting provider.</p>
</div>
</div>

<div ng-show="settings.data.xdebug_max_nesting_level.error">
<div class="readiness-check-content">
<p>
Magento2 requires xdebug.max_nesting_level to be set {{settings.data.xdebug_max_nesting_level.requiredLevel}} or more,
but it set xdebug.max_nesting_level={{settings.data.xdebug_max_nesting_level.currentLevel}}.
</p>
</div>
</div>

</div>
Expand Down

0 comments on commit 8a5f359

Please sign in to comment.