Skip to content

Commit 8a5f359

Browse files
author
Ivan Gavryshko
committed
MAGETWO-33027: [GITHUB] Installation Incomplete with XDebug enabled #904
- added check for xdebug.max_nesting_level
1 parent 0c03986 commit 8a5f359

File tree

4 files changed

+125
-41
lines changed

4 files changed

+125
-41
lines changed

setup/pub/magento/setup/readiness-check.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ angular.module('readiness-check', [])
3232
processed: false,
3333
expanded: false
3434
};
35-
$scope.rawpost = {
35+
$scope.settings = {
3636
visible: false,
3737
processed: false,
3838
expanded: false
@@ -62,16 +62,16 @@ angular.module('readiness-check', [])
6262
$scope.stopProgress();
6363
}
6464
},
65-
'php-rawpost': {
66-
url:'index.php/environment/php-rawpost',
65+
'php-settings': {
66+
url:'index.php/environment/php-settings',
6767
show: function() {
6868
$scope.startProgress();
69-
$scope.rawpost.visible = true;
69+
$scope.settings.visible = true;
7070
},
7171
process: function(data) {
72-
$scope.rawpost.processed = true;
73-
angular.extend($scope.rawpost, data);
74-
$scope.updateOnProcessed($scope.rawpost.responseType);
72+
$scope.settings.processed = true;
73+
angular.extend($scope.settings, data);
74+
$scope.updateOnProcessed($scope.settings.responseType);
7575
$scope.stopProgress();
7676
}
7777
},

setup/src/Magento/Setup/Controller/Environment.php

+67-9
Original file line numberDiff line numberDiff line change
@@ -88,23 +88,28 @@ public function phpVersionAction()
8888
}
8989

9090
/**
91-
* Checks if PHP version >= 5.6.0 and always_populate_raw_post_data is set
91+
* Checks PHP settings
9292
*
9393
* @return JsonModel
9494
*/
95-
public function phpRawpostAction()
95+
public function phpSettingsAction()
9696
{
97-
$iniSetting = ini_get('always_populate_raw_post_data');
9897
$responseType = ResponseTypeInterface::RESPONSE_TYPE_SUCCESS;
99-
if (version_compare(PHP_VERSION, '5.6.0') >= 0 && (int)$iniSetting > -1) {
100-
$responseType = ResponseTypeInterface::RESPONSE_TYPE_ERROR;
98+
99+
$settings = array_merge(
100+
$this->checkRawPost(),
101+
$this->checkXDebugNestedLevel()
102+
);
103+
104+
foreach ($settings as $setting) {
105+
if ($setting['error']) {
106+
$responseType = ResponseTypeInterface::RESPONSE_TYPE_ERROR;
107+
}
101108
}
109+
102110
$data = [
103111
'responseType' => $responseType,
104-
'data' => [
105-
'version' => PHP_VERSION,
106-
'ini' => ini_get('always_populate_raw_post_data')
107-
]
112+
'data' => $settings
108113
];
109114

110115
return new JsonModel($data);
@@ -170,4 +175,57 @@ public function filePermissionsAction()
170175

171176
return new JsonModel($data);
172177
}
178+
179+
/**
180+
* Checks if PHP version >= 5.6.0 and always_populate_raw_post_data is set
181+
*
182+
* @return array
183+
*/
184+
private function checkRawPost()
185+
{
186+
$data = [];
187+
$error = false;
188+
$iniSetting = ini_get('always_populate_raw_post_data');
189+
190+
if (version_compare(PHP_VERSION, '5.6.0') >= 0 && (int)$iniSetting > -1) {
191+
$error = true;
192+
}
193+
194+
$data['rawpost'] = [
195+
'version' => PHP_VERSION,
196+
'ini' => ini_get('always_populate_raw_post_data'),
197+
'error' => $error
198+
];
199+
200+
return $data;
201+
}
202+
203+
/**
204+
* Checks if xdebug.max_nesting_level is set 200 or more
205+
* @return array
206+
*/
207+
private function checkXDebugNestedLevel()
208+
{
209+
$data = [];
210+
$error = false;
211+
212+
$currentExtensions = $this->phpInformation->getCurrent();
213+
if (in_array('xdebug', $currentExtensions)) {
214+
215+
$currentXDebugNestingLevel = intval(ini_get('xdebug.max_nesting_level'));
216+
$minimumRequiredXDebugNestedLevel = $this->phpInformation->getRequiredMinimumXDebugNestedLevel();
217+
218+
if ($minimumRequiredXDebugNestedLevel > $currentXDebugNestingLevel) {
219+
$error = true;
220+
}
221+
222+
$data['xdebug_max_nesting_level'] = [
223+
'currentLevel' => $currentXDebugNestingLevel,
224+
'requiredLevel' => $minimumRequiredXDebugNestedLevel,
225+
'error' => $error
226+
];
227+
}
228+
229+
return $data;
230+
}
173231
}

setup/src/Magento/Setup/Model/PhpInformation.php

+15
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111

1212
class PhpInformation
1313
{
14+
15+
/**
16+
* Allowed XDebug nested level
17+
*/
18+
const XDEBUG_NESTED_LEVEL = 200;
19+
1420
/**
1521
* List of required extensions
1622
*
@@ -59,6 +65,15 @@ public function getRequiredPhpVersion()
5965
}
6066
}
6167

68+
/**
69+
* Returns minimum required XDebug nested level
70+
* @return int
71+
*/
72+
public function getRequiredMinimumXDebugNestedLevel()
73+
{
74+
return self::XDEBUG_NESTED_LEVEL;
75+
}
76+
6277
/**
6378
* Retrieve list of required extensions
6479
*

setup/view/magento/setup/readiness-check/progress.phtml

+36-25
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
</a>
7676
</p>
7777
<p ng-show="version.expanded">
78-
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>.
78+
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>.
7979
</p>
8080
<p ng-show="version.expanded">If you need more help please call your hosting provider.</p>
8181
</div>
@@ -86,15 +86,15 @@
8686

8787
</div>
8888

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

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

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

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

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

@@ -107,29 +107,40 @@
107107

108108
</div>
109109

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

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

119-
<div class="readiness-check-content">
120-
<h3 class="readiness-check-title">PHP Settings Check</h3>
121-
<p>
122-
Your PHP Version is {{rawpost.data.version}}, but always_populate_raw_post_data = {{rawpost.data.ini}}.
123-
<a href="#php-rawpost" ng-click="updateOnExpand(rawpost)">
124-
<span ng-hide="rawpost.expanded">Show detail</span>
125-
<span ng-show="rawpost.expanded">Hide detail</span>
126-
</a>
127-
</p>
128-
<p ng-show="rawpost.expanded">
129-
$HTTP_RAW_POST_DATA is deprecated from PHP 5.6 onwards and will stop the installer from running.
130-
Please open your php.ini file and set always_populate_raw_post_data to -1.
131-
</p>
132-
<p ng-show="rawpost.expanded">If you need more help please call your hosting provider.</p>
115+
<div ng-show="settings.data.rawpost.error">
116+
<div class="rediness-check-side">
117+
<p class="side-title">Need Help?</p>
118+
<a href="http://php.net/manual/en/ini.core.php#ini.always-populate-settings-data" target="_blank">PHP Documentation</a>
119+
</div>
120+
<div class="readiness-check-content">
121+
122+
<p>
123+
Your PHP Version is {{settings.data.rawpost.version}}, but always_populate_raw_post_data = {{settings.data.rawpost.ini}}.
124+
<a href="#php-settings" ng-click="updateOnExpand(settings)">
125+
<span ng-hide="settings.expanded">Show detail</span>
126+
<span ng-show="settings.expanded">Hide detail</span>
127+
</a>
128+
</p>
129+
<p ng-show="settings.expanded">
130+
$HTTP_RAW_POST_DATA is deprecated from PHP 5.6 onwards and will stop the installer from running.
131+
Please open your php.ini file and set always_populate_raw_post_data to -1.
132+
</p>
133+
<p ng-show="settings.expanded">If you need more help please call your hosting provider.</p>
134+
</div>
135+
</div>
136+
137+
<div ng-show="settings.data.xdebug_max_nesting_level.error">
138+
<div class="readiness-check-content">
139+
<p>
140+
Magento2 requires xdebug.max_nesting_level to be set {{settings.data.xdebug_max_nesting_level.requiredLevel}} or more,
141+
but it set xdebug.max_nesting_level={{settings.data.xdebug_max_nesting_level.currentLevel}}.
142+
</p>
143+
</div>
133144
</div>
134145

135146
</div>

0 commit comments

Comments
 (0)