Skip to content

Commit c5c27f1

Browse files
author
Richard McLeod
committed
Add check to see if PHP > 5.6 and always_populate_raw_post_data = -1
1 parent 3fc6455 commit c5c27f1

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ angular.module('readiness-check', [])
3232
processed: false,
3333
expanded: false
3434
};
35+
$scope.rawpost = {
36+
visible: false,
37+
processed: false,
38+
expanded: false
39+
};
3540
$scope.extensions = {
3641
visible: false,
3742
processed: false,
@@ -57,6 +62,19 @@ angular.module('readiness-check', [])
5762
$scope.stopProgress();
5863
}
5964
},
65+
'php-rawpost': {
66+
url:'index.php/environment/php-rawpost',
67+
show: function() {
68+
$scope.startProgress();
69+
$scope.rawpost.visible = true;
70+
},
71+
process: function(data) {
72+
$scope.rawpost.processed = true;
73+
angular.extend($scope.rawpost, data);
74+
$scope.updateOnProcessed($scope.rawpost.responseType);
75+
$scope.stopProgress();
76+
}
77+
},
6078
'php-extensions': {
6179
url:'index.php/environment/php-extensions',
6280
show: function() {

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,29 @@ public function phpVersionAction()
8181
return new JsonModel($data);
8282
}
8383

84+
/**
85+
* Checks if PHP version >= 5.6.0 and always_populate_raw_post_data is set
86+
*
87+
* @return JsonModel
88+
*/
89+
public function phpRawpostAction()
90+
{
91+
$iniSetting = ini_get('always_populate_raw_post_data');
92+
$responseType = ResponseTypeInterface::RESPONSE_TYPE_SUCCESS;
93+
if (version_compare(PHP_VERSION, '5.6.0') >= 0 && (int)$iniSetting > -1) {
94+
$responseType = ResponseTypeInterface::RESPONSE_TYPE_ERROR;
95+
}
96+
$data = [
97+
'responseType' => $responseType,
98+
'data' => [
99+
'version' => PHP_VERSION,
100+
'ini' => ini_get('always_populate_raw_post_data')
101+
]
102+
];
103+
104+
return new JsonModel($data);
105+
}
106+
84107
/**
85108
* Verifies php verifications
86109
*

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

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,59 @@
8585

8686
</div>
8787

88+
<div id="php-rawpost" class="rediness-check-item" ng-show="rawpost.visible">
89+
90+
<h3 class="readiness-check-title" ng-hide="version.processed">
91+
Checking PHP Version and PHP Raw Post Data Settings...
92+
</h3>
93+
94+
<div ng-show="rawpost.processed" ng-switch="rawpost.responseType">
95+
96+
<div ng-switch-when="success" ng-init="updateOnSuccess(rawpost)">
97+
98+
<span class="readiness-check-icon icon-success-round"></span>
99+
100+
<div class="readiness-check-content">
101+
<h3 class="readiness-check-title">PHP Raw Post Data Check</h3>
102+
<p>
103+
You are not populating raw_post_data or your PHP version is less than 5.6.0
104+
</p>
105+
</div>
106+
107+
</div>
108+
109+
<div class="readiness-check-item" ng-switch-default ng-init="updateOnError(rawpost)">
110+
111+
<div class="rediness-check-side">
112+
<p class="side-title">Need Help?</p>
113+
<a href="http://www.php.net/docs.php" target="_blank">PHP Documentation</a>
114+
</div>
115+
116+
<span class="readiness-check-icon icon-failed-round"></span>
117+
118+
<div class="readiness-check-content">
119+
<h3 class="readiness-check-title">PHP Raw Post Data Check</h3>
120+
<p>
121+
Your PHP Version is {{rawpost.data.version}}<br />
122+
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 (uncomment if necessary)
131+
</p>
132+
<p ng-show="rawpost.expanded">If you need more help please call your hosting provider.</p>
133+
</div>
134+
135+
</div>
136+
137+
</div>
138+
139+
</div>
140+
88141
<div id="php-extensions" class="rediness-check-item" ng-show="extensions.visible">
89142

90143
<h3 ng-hide="extensions.processed" class="readiness-check-title">

0 commit comments

Comments
 (0)